whenever i set android:background
="colorxxx" for my ImageButton
, the effect of pressing ImageButton
will lost.
before adding that attribute it has an effect filling the image with dark color
i want it works too when ImageButton
has android:background
="colorxxx"
my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".HomeActivity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:background="@color/ColorPrimary"
android:layout_height="?attr/actionBarSize">
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"
android:src="@drawable/a"
android:layout_weight="50"
android:adjustViewBounds="true" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"
android:src="@drawable/b"
android:layout_weight="50"
android:adjustViewBounds="true" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"
android:src="@drawable/c"
android:layout_weight="50"
android:adjustViewBounds="true" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"
android:src="@drawable/d"
android:layout_weight="50"
android:adjustViewBounds="true" />
</LinearLayout>
The ripple effect is part of the background, like android:background="?attr/selectableItemBackground"
, if you set a background yourself, the ripple will no longer work.
You can instead change the tint of your button as stated in this other response
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With