Android 标高不起作用
我试图在示例应用程序中的按钮上获得Android 标高不起作用,android,material-design,Android,Material Design,我试图在示例应用程序中的按钮上获得4dp高程,但我似乎无法获得任何阴影显示 这是我的代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_
4dp
高程,但我似乎无法获得任何阴影显示
这是我的代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:clipChildren="false"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me"
android:background="@drawable/myrect"
android:elevation="4dp"/>
</LinearLayout>
结果是:
我确实看到过其他类似的帖子。它们都指向一个半透明的背景作为问题,但正如你在这里看到的,我使用的是完全不透明的背景
知道我遗漏了什么吗?对于android 5.0及以上版本,请尝试其他视图的提升
android:elevation="10dp"
对于按钮
android:stateListAnimator="@anim/button_state_list_animator"
按钮\u状态\u列表\u animator.xml
不是真的重复,但答案与相同,即“设置stateListAnimator”
android:elevation="10dp"
android:stateListAnimator="@anim/button_state_list_animator"