I'm migrating an Android App to use Material Design. To verify if I did everything correct i create an empty activity to test some Material Design itens (FAB, raised button, elevation on views, cards, lists, etc...).
The buttons appear to OK, but the elevation on views aren't. I searched the internet for an answer but didn't find it. I'm not using padding, transparent background, etc. Here's my code:
values-v21/styles.xml:
<resources>
<style name="AppThemeNoActionBar" parent="AppTheme">
<item name="android:navigationBarColor">@color/colorPrimary</item>
</style>
<style name="AppTheme" parent="MyMaterialTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Button" parent="Base.Widget.AppCompat.Button.Colored">
<item name="android:backgroundTint">@color/colorAccent</item>
</style>
<color name="colorPrimary">#E88768</color>
<color name="colorPrimaryDark">#CC785C</color>
<color name="colorAccent">#E88768</color>
<color name="textColorPrimary">#000000</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#E88768</color>
</resources>
layout-v21/start_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
xmlns:app="http://schemas.android.com/apk/res-auto">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:elevation="12dp"
android:translationZ="12dp"
android:id="@+id/scrollView">
</HorizontalScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="@+id/scrollView">
</LinearLayout>
</RelativeLayout>
Can anyone help me?
Try setting a background color / drawable to your HorizontalScrollView
:
android:background="@android:color/white"
This seems to be necessary for the shadow to be drawn.
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