jze*_*ino 5 android android-5.0-lollipop android-elevation
我正在尝试在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" />
Run Code Online (Sandbox Code Playgroud)
我的主题是: Theme.AppCompat.Light.DarkActionBar
有了这段代码,我只能得到涟漪.如果我删除背景(波纹),我得到提升.
编辑:
注意:所有屏幕截图都是在点击图像的情况下拍摄的(长按).
我已经测试了android:background="?attr/selectableItemBackground",我得到了一个波纹,背景是一个正方形,但没有高程:
与android:background="?attr/selectableItemBackgroundBorderless"我买了圆形的背景波纹,但没有海拔:
没有背景属性我得到了高程,默认ImageButton背景:
我需要的是圆形波纹背景和高度同时.
现在已经五年了,但我重新审视了这个问题,解决方案是使用foreground而不是background:
<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:elevation="5dp"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:src="@mipmap/ic_launcher"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1431 次 |
| 最近记录: |