2014-05-07 51 views

回答

2

你需要看起來像的繪製文件夾中創建一個形狀drawable

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 
    <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" 
     android:angle="270"/> 
</shape> 

修改顏色代碼。

(在這個例子中我已保存的繪製爲circle.xml,它會有一個漸變填充)

然後在你的佈局,你需要定義一個視圖,設置形狀爲背景:

<View android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:background="@drawable/circle"/> 

視圖定義了形狀的大小和尺寸。

編輯 - 代碼

Graphical View

Code Image

的結果的屏幕截圖