[英]cardview with bottom border
I wanted a cardview with only bottom border. 我想要只有底部边框的Cardview。 So i found a solution : 所以我找到了一个解决方案:
toolbar_background.xml : toolbar_background.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/colorPrimary" />
</shape>
</item>
<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/titleBarBorder" />
</shape>
</item>
</layer-list>
and then i added this .xml to my cardview as a background using android:background="@drawable/toolbar_background"
but the color just wont show up and cardview will render with a white background. 然后我使用android:background="@drawable/toolbar_background"
将这个.xml作为背景添加到我的cardview中,但是颜色不会显示,并且cardview将以白色背景呈现。 what am i doing wrong ? 我究竟做错了什么 ?
I used an image view to set the background xml to card view : 我使用图像视图将背景xml设置为卡片视图:
<android.support.v7.widget.CardView
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="70dp"
app:cardBackgroundColor="@color/colorPrimary"
app:cardElevation="4dp"
app:cardCornerRadius="0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/toolbarbackground"
android:scaleType="fitXY"/>
<cardview contents here>...
</android.support.v7.widget.CardView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.