<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:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
card_view:cardCornerRadius="12dp"
card_view:cardElevation="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
.....
</android.support.v7.widget.CardView>
这是我在layout.xml中设置的
我想在运行时以编程方式更改卡片的背景。
CardView card =(CardView) findViewById(R.id.card_view);
card.setBackgroundResource(R.drawable.card1);
这会将所有半径角设置为 0dp。我想保持半径和背景可绘制。
Use card_view:cardBackgroundColor="#FFFFFFFF"
代替android:background="#FFFFFFFF"
以编程方式使用,card.setCardBackgroundColor(color)
代替card.setBackgroundColor(color)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)