谷歌玻璃浸入式自定义布局不CardBuilder.Layout.EMBED_INSIDE自定义、布局、玻璃、EMBED_INSIDE

2023-09-03 22:19:59 作者:顾及谁@

我试图通过建立一个自定义XML布局的浸泡。

我的理解是,如果我使用CardBuilder,我需要embed_inside,但我想使用整个屏幕与我的XML布局。

现在看来,这种用卡但该接口已经去preciated是previously可能的。

我可能只是缺少一个基本的玻璃概念,而是每一个例子或文档中我读到目前为止,通过CardBuilder.Layout访问并使用predefined玻璃布局。

解决方案

您不需要使用 CardBuilder 如果preFER使用自己的自定义布局:一定要按照我们的设计指南,以确保您符合我们的规范

要使用您的自定义布局,只需一个充气查看,你通常会在你的应用程序中使用。

对于活动,你可以是这样的:

  @覆盖
保护无效的onCreate(束捆){
    super.onCreate(包);
    的setContentView(R.layout.my_custom_layout);
}
 
谷歌公布Android Studio 2.3版本 支持WebP更新

如果您使用的是 CardScrollView ,只需修改 CardScrollAdapter getView 的方法来回报您的查看

  @覆盖
公共查看getView(INT位置,查看convertView,ViewGroup中父){
    //可以使用LayoutInflater膨胀的观点:
    // LayoutInflater.from(mContext).inflate(R.layout.my_custom_layout,父)​​;
    返回mCustomView;
}
 

I am trying to build an immersion via a custom XML layout.

My understanding is if I use CardBuilder, I would need to embed_inside but I wanted to use the entire screen with my XML layout.

It appeared that this was previously possible using card however that interface has been depreciated.

I may just be missing a basic Glass concept, but every example or document I have read so far accesses via CardBuilder.Layout and uses the predefined glass layouts.

解决方案

You don't need to use the CardBuilder if you prefer to use your own custom layout: make sure to follow our design guidelines to make sure you meet our specs.

To use your custom layout, simply inflate a View as you would normally and use in your application.

For an Activity, you could something like:

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.my_custom_layout);
}

If you are using a CardScrollView, simply modify the CardScrollAdapter's getView method to return your View:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // You can inflate the View using a LayoutInflater: 
    //     LayoutInflater.from(mContext).inflate(R.layout.my_custom_layout, parent);
    return mCustomView;
}