0
   <?xml version="1.0" encoding="utf-8"?>
    <gradient>
      <shape xmlns:android="http://schemas.android.com/apk/res/android"
             android:shape="rectangle">
             <gradient android:type="linear"
                       android:centerX="35%" 
                       android:startColor="#FF4D0000" 
                       android:centerColor="#FF4D0000" 
                       android:endColor="#FFe5f011" 
                       android:angle="225"/>
       </shape>

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle" >
             <gradient android:type="radial"
                       android:centerX="50%" 
                       android:centerY="50%" 
                       android:startColor="#FF4D0000" 
                       android:centerColor="#FF4D0000" 
                       android:endColor="#FFe5f011" 
                       android:gradientRadius="35"/>
    </shape>
    </gradient>

这是我形成的称为渐变的形状,我分配它的方式是:

android:background="@drawable/gradient"
4

1 回答 1

0

创建一个 shape 类型的 android xml 文件。命名为 myshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
    android:centerColor="#FF4D0000"
    android:centerX="50%"
    android:centerY="50%"
    android:endColor="#FFe5f011"
    android:gradientRadius="35"
    android:startColor="#FF4D0000"
    android:type="radial" />

</shape>

现在使用“@drawable/myshape”将此文件分配给任何布局

我希望这能消除你的疑虑。布斯卡尼亚。

于 2014-08-26T09:29:09.170 回答