常用属性
自定义边框
基本使用
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle矩形/ring圆环/oval椭圆/line直线"
当为圆环时
android:shape="ring"
android:useLevel="false"如果当作是LevelListDrawable使用时为true,否则为false
android:innerRadius="10dp"内环半径
android:innerRadiusRatio="2"浮点型,以环的宽度比来表示内环的半径
android:thicknessRatio="2"浮点型,以环的宽度比来表示环的厚度
android:thickness="10dp"环的厚度
>
>
<corners角度
android:topLeftRadius="10dp"左上角度
android:topRightRadius="10dp"右上角度
android:bottomLeftRadius="10dp"左下角度
android:bottomRightRadius="10dp"/>右下角度
<stroke描边
android:width="1dp"线宽度
android:dashWidth="3dp"虚线宽度
android:dashGap="3dp"虚线间距
android:color="@color/purple_200"颜色
/>
<padding android:bottom="5dp"内边距
android:top="5dp"
android:left="5dp"
android:right="50dp"/>
<gradient渐变填充
android:angle="270"渐变角度,必须为45的倍数,0从左到右,90从上到下
android:type="sweep扫描式渐变/radia放射渐变/linear线性渐变"
android:startColor="@color/white"开始颜色
android:centerColor="@color/grey"中间颜色
android:endColor="@color/black"结束颜色
android:centerX="0.6"渐变中心X的相当位置,0--1范围
android:centerY="0.1"渐变中心Y的相当位置,0--1范围
android:gradientRadius="5dp"渐变半径,只有radia放射渐变使用
/>
<size图形大小
android:width="100dp"宽度
android:height="100dp"/>高度
</shape>
详细
文本框中的图片使用
具体
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.jay.example.test.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:drawableTop="@drawable/show1"
android:drawableLeft="@drawable/show1"
android:drawableRight="@drawable/show1"
android:drawableBottom="@drawable/show1"
android:drawablePadding="10dp"
android:text="张全蛋" />
</RelativeLayout>