I have FrameLayout with android:elevation="4dp". Shadow of this elevation directed down. I want change direction of shadow to up.
<FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="100dp" android:elevation="10dp" android:layout_marginBottom="100dp" android:background="@color/ColorPrimary" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"> </FrameLayout>
To set the default (resting) elevation of a view, use the android:elevation attribute in the XML layout. To set the elevation of a view in the code of an activity, use the View. setElevation() method. To set the translation of a view, use the View.
No, the color of the shadow provided by the framework cannot be changed.
You need to use a drawable background ( shadow. xml ) in the parent layout which is looking like a shadow. You can replace FF46A9 in shadow. xml to change the color of shadow.
I consider this method is the best solution: Android Bottom Navigation Bar with drop shadow Thanks, Alexander Bilchuk.
Solution:
You can draw your own shadow just above the view using simple View and its background:
<View android:layout_width="match_parent" android:layout_height="4dp" android:layout_above="@id/bottom_bar" android:background="@drawable/shadow"/>
drawable/shadow.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#1F000000" android:endColor="@android:color/transparent" android:angle="90" /> </shape>
Also, there are no compatibility issues if use this approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With