引言:当我们在做项目的时候,背景使用的地方比较多,很多情况下我们会让UI进行切图或者制作.9.png,但是有时候并不能达到很好的效果,加上沟通成本什么的,效率比较低。那么接下来就来看下如何通过xml来制作自己的背静图片。
一:首先制作一张简单的背景(带有圆角的红色背景图)
1:在drawable中右键----new-----Drawable resource file.
2: 给自己的xml文件起一个名字(姑且叫做:shape)。
3:更改selector 为 shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<padding android:left="2dp"
android:top="1dp"
android:right="1dp"
android:bottom="2dp"/>
<solid android:color="@color/red"/>
<corners android:radius="10dp"/>
</shape>
4:此时就可以进行背景的设置了。
二:点击背景状态变化
<?xml ver