Android中自定义TextView的形状--圆形-椭圆形-圆角矩形-线条
16lz
2021-01-23
基本步骤:
在drawable文件夹下建立一个shape.xml
在drawable文件夹下建立一个shape.xml
shape.xml:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FF8C2E"/> <corners android:radius="360dip"/> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" />shape>
在主界面中的main.xml:
android:layout_width="125dp"
android:layout_height="50dp"
android:background="@drawable/shape"
/>
注意:在shape文件中,
表示绘制椭圆:
android:shape="oval"
表示绘制线条:
android:shape="line"
表示圆形:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/colorAccent"/> <corners android:radius="180dip"/> <padding android:left="5dp" android:top="10dp" android:right="5dp" 根据字数多少 大小 边距稍微调一下就能出来 android:bottom="10dp" />shape>
表示绘制矩形;加上半径,则可以绘制圆角矩形。
android:shape="rectangle"
更多相关文章
- AndroidUi(2)-圆角矩形
- android实现圆角矩形
- android圆角矩形的实现
- 如何用C语言计算矩形的周长和面积?(附代码)
- C语言怎么计算矩形的面积和周长
- c语言实现输入圆的半径计算圆的面积
- HTML5中canvas实现矩形颜色渐变
- 矩形嵌套 DP 南阳理工 http://acm.nyist.net/JudgeOnline/proble
- Android圆弧形ListView的实现