No Shadow In Appcompat And Design Library
My problem is there isn't shadow in my app. I am using AppCompat Libary, and Design Library. In preview (android studio) there is shadow, BUT I can't see in my app on the phone. He
Solution 1:
There is no default shadow unfortunately (or at least as near as I can tell, I am happy to be corrected). However, in your case, there is at least one workaround.
First, create a drawable
xml
file to represent your shadow (i.e. app_bar_shadow.xml
):
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#02444444"
android:endColor="#33111111"
android:angle="90"/>
</shape>
Then add it to your layout
, and assign it a scrolling behaviour. Place it just underneath your NestedScrollView
in your layout
file:
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:id="@+id/app_bar_shadow"
android:layout_gravity="top"
android:background="@drawable/app_bar_shadow"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Solution 2:
Shadow is available starting from lollipop, are you using a phone/emulator with an older android? Unfortunately appcompat does not solve this issue for older androids
Post a Comment for "No Shadow In Appcompat And Design Library"