【发布时间】:2017-10-01 13:17:22
【问题描述】:
我正在尝试在 Imagebutton 中实现波纹效果。
activty_main.xml
<ImageButton
android:id="@+id/idbuttonsix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/iconagift"
android:background="@drawable/ripple_effect"
我已尝试实现此代码,但触摸时 ImageButton 上没有涟漪效果:
android:foreground="?android:attr/selectableItemBackground"
还有这个
android:background="?attr/selectableItemBackgroundBorderless"
我正在寻找可以一步一步帮助我的人。
ripple_effect.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item>
<shape
android:shape="rectangle">
<solid android:color="#4CAF50" />
</shape>
</item>
【问题讨论】:
-
您在哪个 Android 版本上运行应用程序?还发布您的ripple_effect.xml
-
android:clickable="true"试试这个 -
@NabinBhandari 这个应用程序 - minSdkVersion 21 和 targetSdkVersion 26
标签: android imagebutton