7

LinearLayout バックグラウンドとして次のドローアブル セットを取得しました。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
      <bitmap
         android:tileMode="repeat"
         android:dither="true"
         android:src="@drawable/bg"/>
   </item>


   <item>
      <shape android:shape="rectangle">
         <gradient
            android:startColor="#ffff0000"
            android:endColor="#ff00ff00"
            android:centerX="50%"
            android:centerY="50%"
            android:gradientRadius="50%"
            android:type="radial"/>
      </shape>
   </item>
</layer-list>

docsによると、gradientRadius はウィンドウ/親サイズのパーセンテージに設定できます。残念ながら...うまくいきません。半径は 0 です。何が間違っていますか? または、Android の何が問題になっていますか?

画面全体を埋めるために放射状グラデーションが必要です。回避策は何ですか?

4

2 に答える 2

5

必要なものをよく理解している場合は、ドローアブルで参照されるレイアウトを作成する必要があります

( "match_parent" ) 、

以下のように :

 <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/"your drawable xml name">

この助けを願っています。

于 2012-05-27T16:51:47.937 に答える