我正在将一个Android应用迁移到使用Material Design。为了验证我是否做得正确,我创建了一个空活动来测试一些Material Design项目(FAB、凸起按钮、视图高程、卡片、列表等等)。
按钮看起来很好,但是视图高程不太对。我在互联网上搜索了答案,但没有找到。我没有使用填充、透明背景等。以下是我的代码:
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>
有人能帮我吗?