1、在drawable中建立bg.xml文件 <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <gradient android:startColor=”@color/white” android:centerColor=”@color/gray” android:endColor=”@color/black” android:angle=”270″ <!–0是从左到右,90是从下到上,180从右到左,270从上到下–> android:centerY=”0.3″ android:centerX=”0.3″ <!—-> /> <corners android:radius=”0dip”/> </shape> 2、这样在布局中就可以使用 <LinearLayout android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”@drawable/xml_bg_orange” android:orientation=”horizontal” > 3、这样背景就会从上到下进行颜色渐变