2016-11-30 75 views
0

我搜索了有關陰影按鈕(如下所示)但未找到想要的結果。我想要如下圖所示。將傳播陰影添加到按鈕的底部Android

enter image description here

我想這也How to provide shadow to Button

我也試過仰角和平移Z(z)的Android方法的陰影,但沒有任何幫助。請通過這個指導我。 謝謝。

+0

使用高程提供您的結果。 –

+0

http://stackoverflow.com/questions/15333529/how-to-provide-shadow-to-button?noredirect=1&lq=1 – ThanhTranIT

+0

android:translateZ =「@ null」 android:elevation =「24dp」 –

回答

1
Create your own xml file in side drawable folder and set in your button backround. 

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <!--the shadow comes from here--> 
    <item 
     android:bottom="-6dp" 
     android:drawable="@android:drawable/dialog_holo_light_frame" 
     android:left="-6dp" 
     android:right="-6dp" 
     android:top="-6dp"> 

    </item> 

    <item 
     android:bottom="-6dp" 
     android:left="-6dp" 
     android:right="-6dp" 
     android:top="-6dp"> 

     <shape android:shape="rectangle"> 
      <solid android:color="@color/transparent" /> 

     </shape> 
    </item> 
</layer-list> 
+0

其顯示對話框陰影,但我使用自己的粉紅色陰影與圓角。它如何實現? –

+0

無論你想要什麼改變你的純色。 – Umesh

+0

我不說基礎顏色。我說對話的背景陰影是黑色的,但我想粉紅色。並且對話陰影不像我的圖像那樣傳播。 –

0

使用此代碼

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item > 
    <shape 
     android:shape="rectangle"> 
    <solid android:color="@color/your_btncolor" /> 
    <corners android:radius="5dp"/> 
    </shape> 
</item> 
<item android:right="-5dp" 
     android:left="-5dp" 
     android:bottom="-15dp"> 
    <shape 
     android:shape="rectangle"> 
    <solid android:color="@color/your_btn_shadowcolor"/> 
    <corners android:radius="5dp"/> 
    </shape> 
</item> 
</layer-list> 
+0

你的代碼在簡單的線條下繪製不是一個陰影。 –

+0

看到我編輯的答案 –