在android 开发应用中,大部份的开发人员都会使用背景图作为项目的背景,其实使用style.xml配置也可以实现比较漂亮的背景样式。
在/drawable/下创建一个bg.xml 文件,用来定义项目的背景样式。
文件内容如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#ffe5e9ed"
android:endColor="#ffc3dae6"
android:angle="270" />
</shape>
定义一个渐变的轮廓,渐变的起始颜色和终止颜色。
在你的布局文件里面条用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/bg" >
</LinearLayout>
定义样式文件可以更加灵活调整。
1232

被折叠的 条评论
为什么被折叠?



