如何在cardview上设置彩色边框 [英] how to set colored border on cardview
本文介绍了如何在cardview上设置彩色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实现卡片视图,但是找不到任何可以在其上设置边框的边框选项.
I am implementing card view but I can't find any border option to set a border on it.
这是我的card.xml:
here is my card.xml:
<android.support.v7.widget.CardView android:layout_marginTop="10dp"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
card_view:cardPreventCornerOverlap="false"
app:cardPreventCornerOverlap="false"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:background="@drawable/tab_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
这是我要在卡片视图上实现绿色边框的图片吗?
here is my image that I want to implement that green border on card view?
帮帮我.我该如何实施呢?我不知道.
Help me. How can I implement this thing? I have no clue.
谢谢.
推荐答案
创建可绘制的selector.xml
Create drawable selector.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#808080"/>
<stroke android:width="3dp" android:color="#B1BCBE" />
<corners android:radius="20dp"/>
<padding android:left="0dp" android:top="0dp"
android:right="0dp" android:bottom="0dp" />
</shape>
然后将其设置为背景,根据您的选择更改颜色
then give set this as a background, change color according your choice
这篇关于如何在cardview上设置彩色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文