设置圆角渐变的TextView
第一步:在Drawable创建bg.xml 文件
如下所示
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--设置圆角的半径--> <corners android:radius="50dp"></corners> <!--指定使用渐变背景色 颜色从红色-绿色-蓝色--> <gradient android:centerColor="#0f0" android:endColor="#00f" android:startColor="#f00"></gradient> </shape>第二步:在TextView中引入
<TextView android:textSize="50sp" android:background="@drawable/bg1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="圆角渐变" />效果图如下: