【发布时间】:2020-10-22 17:15:28
【问题描述】:
我有一个圆角的卡片视图:
<androidx.cardview.widget.CardView
android:id="@+id/chronology_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
app:cardCornerRadius="12dp"> <------- corner radius set in the layout.
视图显示为圆角。 -> 好的。
通过代码设置背景色时...
holder.cardView.setBackgroundColor(getBackgroundColor());
...然后圆角消失了。它看起来像一个具有正确新颜色的矩形。
如何在运行时设置背景色并保持边角?
【问题讨论】: