大佬教程收集整理的这篇文章主要介绍了android – 黑暗主题CardViews周围的白色边框,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
卡片布局使用黑暗主题.我的应用程序使用默认材质主题(黑暗).我正在测试Pixel C,Android 6.0.1.
<android.support.v7.widget.CardView xmlns:android="@R_674_10107@://scheR_764_11845@as.android.com/apk/res/android" xmlns:card_view="@R_674_10107@://scheR_764_11845@as.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" style="@style/CardView.Dark"> <!-- 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); Lay@R_874_9981@nflater lay@R_874_9981@nflater = (Lay@R_874_9981@nflater) context.getSystemservice(Context.LAYOUT_INFLATER_serviCE); View view = lay@R_874_9981@nflater.inflate(R.layout.my_card_view_layout,this); }
我看到的就是这个.卡内容部分看起来很好..深色.但是CardView周围的边距/间隙是白色的.如何让它变得透明,为什么暗卡主题表现如此?此外,在这样的黑暗主题上阴影会是什么样子?
因为我是以编程方式创建这个小部件,所以我认为我需要扩展CardView.这是错的.
之前:
public class MyCustomWidget extends CardView
后:
public class MyCustomWidget extends LinearLayout{ public MyCustomWidget(Context context) { super(context); Lay@R_874_9981@nflater lay@R_874_9981@nflater = (Lay@R_874_9981@nflater) context.getSystemservice(Context.LAYOUT_INFLATER_serviCE); View view = lay@R_874_9981@nflater.inflate(R.layout.my_card_view_layout,this);
以上是大佬教程为你收集整理的android – 黑暗主题CardViews周围的白色边框全部内容,希望文章能够帮你解决android – 黑暗主题CardViews周围的白色边框所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。