[英]Android: why are CardView margins not showing white background?
我在 RecyclerView 列表中设置了 CardView。 layout_marginTop 和 layout_marginBottom 显示的是灰色而不是我希望看到的白色背景(下图)。 关于如何让顶部和底部边距显示白色背景的任何想法?
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="6dp"
android:layout_margin="4dp">
<TextView
android:id="@+id/cardText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:background="@android:color/white" />
</android.support.v7.widget.CardView>
删除了TextView背景,并将此背景添加到CardView中:“ card_view:cardBackgroundColor =” some color“”
Add some margin to card
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
app:cardCornerRadius="2dp"
app:cardElevation="4dp">
</android.support.v7.widget.CardView>
确保您实际上是用域模型中的数据填充它,即检查您是否已实现<data>
和<variable>
标签,并且您已将android:text="@{}"
设置为适当的对象.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.