android shape 的使用
做个笔记,只是为了自己用的时候好找。
background.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 默认为方形 可用android:shape调节形状 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!--颜色渐变 angle为渐变角度-->
<gradient
android:startColor="#FFD63DB7"
android:endColor="#FF72CAE1"
android:angle="90"
>
</gradient>
<!-- 设置圆角 -->
<corners android:radius="30dp"></corners>
<!-- 内边距 -->
<padding android:top="20dp"></padding>
<!-- 实心 就是填充的意思-->
<!-- <solid ></solid> -->
<!-- 描边 -->
<stroke android:width="3dp" android:color="#5525B141"></stroke>
</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=".MainActivity"
android:background="@drawable/background">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试" >
</TextView>
</RelativeLayout>
效果图
做的漂亮点可以直接替代图片。省app的大小了

浙公网安备 33010602011771号