2017-09-29 8 views
2

私は自分のレイアウトの背景として機能するドロアブルを作成しようとしていて、真ん中に2つのソリッドカラーを表示することはできません。2つの単色で描画可能

現在、私はバックグラウンドがソリッドでレイヤーリストを使用しようとしています。半透明の白い矩形のオーバーレイは、矩形の上半分に沿って元のソリッドバックグラウンドカラーに色合いを付けます。このようにする必要はありません。

移行を即座に行う方法が見つからない限り、グラジエントは機能しません。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape android:shape="rectangle"> 
     <size android:height="@dimen/basic_runners_height"></size> 
     <solid android:color="@color/brb_orange" 
      android:gravity="bottom"></solid> 
    </shape> 
</item> 
<item> 
    <shape android:shape="rectangle"> 
     <size android:height="@dimen/basic_runners_height_halved"></size> 
     <solid android:color="@color/md_white_1000" 
      android:alpha="127" 
      android:gravity="top"></solid> 

    </shape> 
</item> 

だから、この私の理解では、2つの形状、他の半分の大きさがなければならないということです。最初の形状は、オレンジ色のドローイング全体をカバーし、もう1つは白で、透過率は約50%(アルファ= 127)で、drawableの半分を取り上げ、上に向かって重力を取ります。

ドロアブルのプレビューは完全に白で、オレンジ色のヒントはありません。私は間違って何をしていますか?

編集:

右、これがさらに簡単にする私も、透明性を気にする必要はないように、私は私の@colorに着色色を追加しました。 XMLは以下の通りです:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item android:top="@dimen/basic_runners_height_halved"> 
    <shape android:shape="rectangle" > 
     <size android:height="@dimen/basic_runners_height_halved" /> 
     <solid android:color="@color/brb_orange_tint" /> 
    </shape> 
</item> 

<item android:top="@dimen/basic_runners_height"> 
    <shape android:shape="rectangle" > 
     <size android:height="@dimen/basic_runners_height" /> 
     <solid android:color="@color/brb_orange" /> 
    </shape> 
</item> 

しかし、これも、トリックを行いません... runners_height_halved runners_heightの半分DPであるが、これは真ん中にそれを分割しません。たぶんドロアブルの10%は着色された色であり、何らかの理由でそれらが色づけされた色が底になるように逆にされる。これは最も単純なものでなければなりません...

答えて

0

<item>タグのパディング(上、左、右、下)を使用してみてください。希望があれば

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape android:shape="rectangle"> 
     <size android:height="@dimen/basic_runners_height"></size> 
     <solid android:color="@color/brb_orange" 
      android:gravity="bottom"></solid> 
    </shape> 
</item> 
<item android:top="10dp" 
     android:left="10dp" 
     android:right="10dp" 
     android:bottom="10dp"> 
    <shape android:shape="rectangle"> 
     <size android:height="@dimen/basic_runners_height_halved"></size> 
     <solid android:color="@color/md_white_1000" 
      android:alpha="127" 
      android:gravity="top"></solid> 

    </shape> 
</item> 
関連する問題