【发布时间】:2016-08-30 06:17:34
【问题描述】:
我正在尝试在 ImageButton 上同时设置高程和波纹效果。 我正在运行 LOLLIPOP。
代码如下:
<android.support.v7.widget.AppCompatImageButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/add" />
我的主题是:Theme.AppCompat.Light.DarkActionBar
使用此代码,我只会得到涟漪。 如果我删除背景(波纹),我会得到提升。
已编辑:
注意:所有屏幕截图都是在点击图片时截取的(长按)。
我用android:background="?attr/selectableItemBackground" 进行了测试,我得到了一个波纹,背景是一个正方形,但没有高程:
使用android:background="?attr/selectableItemBackgroundBorderless",我得到了一个圆形背景的波纹,但没有高程:
没有背景属性我得到了海拔,默认ImageButton背景:
我需要的是同时具有圆形波纹背景和高程。
【问题讨论】:
-
您使用的是无边框背景。无边框元素不会有阴影。这就是为什么。
-
你用的是什么主题?
-
我已经用该信息更新了问题。
-
解决了吗?
标签: android android-5.0-lollipop android-elevation