ITeye博客

android UI入门三 自定义背景样式

fokman · 2012-08-01 15:23 · android · 移动开发 · Markdown

在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>

定义样式文件可以更加灵活调整。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。