<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。我希望保留圆角和背景可绘制对象。