1

i just try to add an shadow to my View and i test many methods i found in stackoverflow and google none of them make shadow like elevation but i faced an problem when i test my app in kitkat i did't see any shadow so what the solution for this use drawable as shadow not give effect like elevation

some of code i used for make shadow but as i said its effect different of elevation

<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@android:color/transparent" 
android:endColor="@color/black_alpha_12" android:angle="90.0" />
</shape>

and

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="rectangle">
        <solid android:color="#BDBDBD"/>
        <corners android:radius="5dp"/>
    </shape>
</item>

<item
    android:left="0dp"
    android:right="0dp"
    android:top="0dp"
    android:bottom="2dp">
    <shape android:shape="rectangle">
        <solid android:color="#ffffff"/>
        <corners android:radius="5dp"/>
    </shape>
</item>
</layer-list>

and more and more code i test its like a line not a shadow only elevation give to me the best shadow

at the end this is my gradle

compileSdkVersion 25
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "blabla.mmmmmm.com"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

so i just need an method for made an shadow just like elevation

shadow needed like this image

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Medo Zeus
  • 99
  • 2
  • 9
  • As i know, shadows are supported from API level 21 and above. Maybe you give it a try to ViewCompat.setElevation(View, int), otherwise the way you did is a nice way to make shadows in KitKat – Emre Aktürk Dec 13 '17 at 19:07
  • @EmreAktürk but i have messenger facebook on kitkat and its have shadow how he do it ? – Medo Zeus Dec 13 '17 at 19:09
  • Check it out, looks like same solution as you did. Maybe facebook did same trick like you did. I have done in one of my projects too. https://stackoverflow.com/questions/26728570/android-appcompat-21-elevation – Emre Aktürk Dec 13 '17 at 19:11

0 Answers0