<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="1dp" android:color="@android:color/darker_gray" /> <solid android:color="@android:color/white"/> <corners android:radius="9dp" android:topLeftRadius="9dp" android:topRightRadius="9dp" android:bottomLeftRadius="9dp" android:bottomRightRadius="9dp"/><!-- 设置圆角半径 --> </shape>在drawable文件夹下面新建text_view_border.xml
在布局文件调用: <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设置圆角
xml设置圆角
最新推荐文章于 2021-09-27 21:52:22 发布