TextView添加椭圆边框

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38875767/article/details/85047314

在Drawable文件里创建textview_background

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 设置透明背景色 -->
    <solid android:color="#f2f2f2" />

    <!-- 设置一个黑色边框 -->
    <stroke
        android:width="2px"
        android:color="#000000" />
    <!-- 设置四个圆角的半径 -->
    <corners
        android:bottomLeftRadius="180px"
        android:bottomRightRadius="180px"
        android:topLeftRadius="180px"
        android:topRightRadius="180px" />
    <!-- 设置一下边距,让空间大一点 -->
    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />

</shape>

然后把这个背景给textView添加进去

 android:background="@drawable/artical_text_background"

大功告成

猜你喜欢

转载自blog.csdn.net/qq_38875767/article/details/85047314