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 の 1 つの 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 に答える