我正在开发将CardView
与RecyclerView
结合使用的应用。
主题是AppCompat.DayLight
。卡片主要是白色背景,recyclerview也是如此,但是比卡片背景要暗一些,这是默认值,来自DayNight主题,我相信。
但是,我不知道这些颜色的确切值或名称,因为我不得不在其他地方使用这些值。
有人可以用这些价值观帮助我吗?
尝试此行
app:cardBackgroundColor="@color/yourColor"
在xml文件中,您可以添加它
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/yourColor">
</android.support.v7.widget.CardView>
编辑
尝试下面的代码行
<style name="CustomCardview1" parent="CardView">
<item name="cardBackgroundColor">#F3921F</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">10dp</item>
</style>
<style name="CustomCardview2" parent="CardView">
<item name="cardBackgroundColor">#F3931F</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">10dp</item>
</style>
在需要卡片视图的布局中编写下面的代码行
<android.support.v7.widget.CardView
style="@style/CustomCardview">
我希望理解正确