我想在线性布局中设置卡之间的间隙,所以我定义了一个边距.
卡片布局使用黑暗主题.我的应用程序使用默认材质主题(黑暗).我正在测试Pixel C,Android 6.0.1.
<androID.support.v7.Widget.CardVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:card_vIEw="http://schemas.androID.com/apk/res-auto" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginStart="15dp" androID:layout_marginEnd="15dp" card_vIEw:cardUseCompatpadding="true" card_vIEw:cardPreventCornerOverlap="false" card_vIEw:cardElevation="5dp" ><!-- content here --></androID.support.v7.Widget.CardVIEw>
我将它们添加到列表视图中:
linearLayout.LayoutParams layoutParams = new linearLayout.LayoutParams(tableRow.LayoutParams.FILL_PARENT,tableRow.LayoutParams.WRAP_CONTENT);linearLayout newlinearLayout = new linearLayout(this);newlinearLayout.setLayoutParams(layoutParams);newlinearLayout.setorIEntation(linearLayout.HORIZONTAL);mainLayoutContainer.addVIEw(newlinearLayout);newlinearLayout.addVIEw(mycardlayoutObj);
使用CardVIEw布局的类实际上扩展了CardVIEw本身,例如
public class MyCustomWidgetextends CardVIEw{ public MyCustomWidget(Context context) { super(context); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); VIEw vIEw = layoutInflater.inflate(R.layout.my_card_vIEw_layout,this);}
我看到的就是这个.卡内容部分看起来很好..深色.但是CardVIEw周围的边距/间隙是白色的.如何让它变得透明,为什么暗卡主题表现如此?此外,在这样的黑暗主题上阴影会是什么样子?
解决方法 所以我有一个布局文件,其中包括< CardVIEw>如上所述.我的自定义类膨胀了这个布局扩展了CardVIEw.所以,我在CardVIEw中有一个CardVIEw. “外部”卡片视图,即我的自定义类扩展的视图,从未设置过主题,因此它使用默认的“light”主题.因为我是以编程方式创建这个小部件,所以我认为我需要扩展CardVIEw.这是错的.
之前:
public class MyCustomWidget extends CardVIEw
后:
public class MyCustomWidget extends linearLayout{ public MyCustomWidget(Context context) { super(context); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); VIEw vIEw = layoutInflater.inflate(R.layout.my_card_vIEw_layout,this);总结
以上是内存溢出为你收集整理的android – 黑暗主题CardViews周围的白色边框全部内容,希望文章能够帮你解决android – 黑暗主题CardViews周围的白色边框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)