2016-05-04 23 views
5

我试图在ImageButton上同时设置高程和纹波效果。 我正在运行LOLLIPOP。在ImageButton中使用高程和纹波

下面是代码:

<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背景:

我需要的是一个圆形纹波背景和高程,同时

+0

您正在使用无边框背景。无边界元素不会有阴影。这就是为什么。 – Budius

+0

你正在使用什么主题? – Lemao1981

+0

我用这些信息更新了问题。 – jzeferino

回答

1

就像阴影一样,无边界的涟漪投射到最近的父表面上 - 这意味着它们不能投射阴影。考虑使用边界波纹代替:

android:background="?attr/selectableItemBackground" 
+0

感谢您的回答,请看看编辑后的问题。 – jzeferino