Android 具有圆形背景的文本视图
我希望我的Android 具有圆形背景的文本视图,android,xml,Android,Xml,我希望我的TextView有圆形边框,并希望戒指充满红色 card\u text\u border.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="10dp" android:thickness="15dp" android:useLevel="false" android:shape="ring" > <
TextView
有圆形边框,并希望戒指充满红色
card\u text\u border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="10dp"
android:thickness="15dp"
android:useLevel="false"
android:shape="ring" >
<solid
android:color="@color/PrimaryDarkColor"/>
<stroke
android:width="4px"
android:color="#000000" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#A6ffffff"/>
<stroke android:width="0dp" android:color="#fff" />
<size android:width="28dp" android:height="28dp"/>
</shape>
以下是解决方案:
循环_textview.xml代码
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<corners android:radius="10dip" />
<stroke
android:width="5dip"
android:color="@color/red" />
<solid android:color="@color/red" />
这里是main.xml中的textView
<TextView
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:background="@drawable/circular_textview"
android:gravity="center"
android:padding="5dp"
android:text="@string/tag_2"
android:textColor="@color/white"
android:textSize="12sp" />
这将帮助您。使用以下代码: White\u circle\u drawable.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="10dp"
android:thickness="15dp"
android:useLevel="false"
android:shape="ring" >
<solid
android:color="@color/PrimaryDarkColor"/>
<stroke
android:width="4px"
android:color="#000000" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#A6ffffff"/>
<stroke android:width="0dp" android:color="#fff" />
<size android:width="28dp" android:height="28dp"/>
</shape>
这么好的答案,我要补充一下 首先,创建一个可绘制的文件并添加以下代码,这样就可以开始了
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#A6E41010" />
<size
android:width="36dp"
android:height="36dp" />
<corners android:radius="18dp" />
</shape>
我无法编辑您的回复,因为我的编辑少于六个字符,但您的结束形状标记被截断,使代码无法正常工作。您应该将形状标记括在xml@Ahmad.ya的末尾,就像我查看它一样,并按照您所说的添加结束标记来更改它。然后我意识到我已经有一个了!!!所以我不得不编辑它,然后改回去。