[转]怎么把一个textview的背景图片设置成圆角的?

 

 
 
在drawable文件夹下新建一个文件设置背景样式
代码:
在drawable文件夹下面新建text_view_border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#80858175" />
<stroke android:width="1dip" android:color="#aea594" />
<corners android:topleftradius="2dp"
android:toprightradius="2dp"
android:bottomrightradius="2dp"
android:bottomleftradius="2dp"/>
</shape>

在布局文件调用:
<textview
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/text_view_border" />

在类文件中调用:
tv.setbackgroundresource(r.drawable.text_view_border);

分析:
solid设置填充颜色,颜色值以#80开头表示透明
stroke 设置边框宽度,颜色值
corners设置圆角
原文地址:https://www.cnblogs.com/ZhuRenWang/p/4903050.html