2016-09-20 8 views
2

を使用して、影のようなショーの勾配は直線的で、ボタンをラップしていますレイアウトと私はレイアウトの上にグラデーションを与えたいと思います。アンドロイド:こんにちは、私は画像からshape.xml</p> <p><a href="https://i.stack.imgur.com/byuKw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/byuKw.png" alt="enter image description here"></a></p> <p>を使用して唯一の上にグラデーションのような影を取得しようとしていますshape.xml

アムは、以下のようにやっていますが、レイヤリストを使用する

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item> 
     <shape 
     android:shape="rectangle"> 
      <stroke android:width="1dp" android:color="#f0f0f0" /> 
      <solid android:color="#f0f0f0" /> 

     </shape> 
    </item> 

    <item android:top="1dp"> 
     <shape 
     android:shape="line"> 
     <gradient 

     android:angle="90" 
     android:type="linear" 
     android:startColor="#FFFFFF" 
     android:endColor="#000000" /> 
     </shape> 
    </item> 

</layer-list> 

答えて

3

不要にワークアウトされていない、あなたはGradientでそれを行うことができます。この流れのコードを試してみてください - >

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient android:startColor="#b4909090" android:endColor="#b4fafafa" android:angle="90"/> 
</shape> 

変更startColorendColorあなたが望むよう。そして、結果は - >

Image For Shadow

+0

コードが全体の直線layout..justに勾配を与えていることをhari86 @レイアウト – hari86

+0

に行をしたい、理解していませんでしたあなたのポイント。 –

1

単純に使用します。

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > 
<gradient 
    android:type="linear" 
    android:centerX="78%" 
    android:startColor="#FFf7f7f7" 
    android:centerColor="#FFC0C0C0" 
    android:endColor="#FFbebebe" 
    android:angle="90"/> 
</shape> 
関連する問題

 関連する問題