您的位置:首页 > 其它

《疯狂安卓讲义》P86 -- 实例:圆角边框、渐变背景的TextView

2018-03-12 15:57 477 查看
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"    >    <!--指定背景-->    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="带边框的文本"        android:textSize="24pt"        android:background="@drawable/bg_border"        />
    <TextView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="圆角边框、渐变背景的文本"        android:textSize="24pt"        android:background="@drawable/bg_border2"        /></LinearLayout>
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <!--设置背景色为透明色-->    <solid android:color="#0000"/>    <!--设置红色边框-->    <stroke android:width="4px"        android:color="#f00"/></shape>
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">    <!--指定圆角矩形的4个圆角的半径-->    <corners android:topLeftRadius="20px"        android:topRightRadius="5px"        android:bottomRightRadius="20px"        android:bottomLeftRadius="5px" />    <!--指定边框线条的宽度和颜色-->    <stroke android:width="4px"        android:color="#f0f" />    <!--指定使用渐变背景色,使用sweep类型的渐变颜色从红到绿到蓝-->    <gradient android:startColor="#f00"        android:centerColor="#0f0"        android:endColor="#00f"        android:type="sweep" /></shape>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安卓开发