好吧,所以我知道涟漪效应只有棒棒糖和以上。但是,尽管如此,在设置image button时,我还是无法获得像“常规”按钮一样工作的良好涟漪效果,只需显示图像(和透明背景)。
我添加了appcompat v7,并将第二个布局放在drawable/layout-v21文件夹中,其中包含以下按钮:

<ImageButton
    android:id="@+id/forward"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:width="15dp"
    android:scaleType="fitCenter"
    android:height="15dp"
    android:padding="25dp"
    style="@style/Widget.AppCompat.ImageButton"
    android:src="@drawable/forwardplay" />

但背景是灰色的,波纹(灰色也)无法定制。
所以,如果我能在我的drawable-v21中加入一个很好的波纹drawable,那就太好了,我可以从imagebutton的background属性引用它。问题是我找不到最初的安卓涟漪效应(我有一部三星s6手机,是三星的主题吗?)
如果有人能分享他们的工作拖拉。
谢谢!

最佳答案

试试这个,肯定会有用的:

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@android:drawable/YOUR_BUTTON_SOURCE"
    android:background="?attr/selectableItemBackgroundBorderless"
/>

关于android - Android imagebutton波纹效果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41165909/

10-09 04:47