-1

trying to put shadow on button with transparent color.

trying with this selection.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
        <solid android:color="#00808080" />
        <!-- <gradient
             android:angle="315"
             android:startColor="#1Acccccc"
             android:endColor="#00cccccc"
             android:type="linear"
             />-->
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
        <solid android:color="#10808080" />
        <!--<gradient
            android:angle="315"
            android:startColor="#00cccccc"
            android:endColor="#1Acccccc"
            android:type="linear"
            />-->
    </shape>
  </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
        <!--<solid android:color="#20808080"/>-->
        <gradient
            android:angle="315"
            android:endColor="#20808080"
            android:startColor="#00cccccc"
            android:type="linear" />
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
        <!--<solid android:color="#30808080"/>-->
        <gradient
            android:angle="315"
            android:endColor="#30808080"
            android:startColor="#00cccccc"
            android:type="linear" />
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
        <!--<solid android:color="#50808080"/>-->
        <gradient
            android:angle="315"
            android:endColor="#50808080"
            android:startColor="#00cccccc"
            android:type="linear" />
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
    </shape>
 </item>
 <item>
    <shape>
        <padding
            android:bottom="1.5dp"
            android:left="0dp"
            android:right="1.5dp"
            android:top="0dp" />
    </shape>
 </item>

 <!-- Background -->
 <item>
    <shape>
        <solid android:color="#80FFFFFF" />
        <corners android:radius="0dp" />
    </shape>
 </item>
</layer-list>
Adriaan
  • 17,741
  • 7
  • 42
  • 75
Himank shah
  • 131
  • 13

2 Answers2

0

i am using this code for shadow its work for me....!

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
    <item android:right="5dp" android:top="5dp">
        <shape>
            <corners android:radius="3dp" />
            <solid android:color="#D6D6D6" />
        </shape>
    </item>
    <item android:bottom="2dp" android:left="2dp">
        <shape>
            <gradient android:angle="270" 
                android:endColor="#E2E2E2" android:startColor="#BABABA" />
            <stroke android:width="1dp" android:color="#BABABA" />
            <corners android:radius="4dp" />
            <padding android:bottom="10dp" android:left="10dp" 
                android:right="10dp" android:top="10dp" />
         </shape>
       </item>
     </layer-list>
   </item>

 </selector>
Nowshad
  • 294
  • 1
  • 14
  • Please read [answer] and [edit] your answer to contain an explanation as to why this code would actually solve the problem at hand. Always remember that you're not only solving the problem, but are also educating the OP and any future readers of this post. – Adriaan Oct 17 '22 at 11:42
0

As I understood, you need something like this?

<?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="#cabababa"/>
            <corners android:radius="2dp"/>
        </shape>
    </item>

    <item
        android:left="0dp"
        android:right="2dp"
        android:top="0dp"
        android:bottom="2dp">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="0dp" />
        </shape>
    </item>
</layer-list>
Alexander
  • 857
  • 6
  • 10
  • Please read [answer] and [edit] your answer to contain an explanation as to why this code would actually solve the problem at hand. Always remember that you're not only solving the problem, but are also educating the OP and any future readers of this post. – Adriaan Oct 17 '22 at 11:42