安卓shape背景

安卓界面
设计button 或者各种text时,可以使用## android:background="@drawable.shape"

button_shape

在drawable里新建button_shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
      <!-- 设置button内部的颜色,此处选择为蓝色 -->
    <solid android:color="#09c2f5"/>
    <!-- 设置button圆角,数值代表大小 -->
    <corners android:radius="8px"/>
     <!-- 设置button边界颜色,数值代表宽度 -->
    <stroke android:color="#e9efec"
        android:width="2px"
        />
</shape>

渐变界面
`<shape xmlns:android="http://schemas.android.com/apk/res/android"
     <!--形状为四方形--!>
    android:shape="rectangle">
    <gradient
        android:angle="135"
        <!--依次设置开始中间结尾颜色--!>
        android:centerColor="#f25660"
        android:startColor="#63c0d4"
        android:endColor="#9fde7b"
        android:type="linear" />
</shape>`

猜你喜欢

转载自blog.csdn.net/heshuyu123/article/details/78019100
今日推荐