Reputation: 229
I wish to create the same activity like in google fit
And I created an activity with android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ddd"
android:orientation="vertical"
tools:context=".MainActivity">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="12dp"
android:background="@null"
android:onClick="onPreferencesClick"
android:src="@drawable/ic_more_vert_grey600_24dp" />
But when I click on three dots button
it doesn't have any push effect in ui, but onPreferencesClick
works fine.
How to create pushable ImageButton
?
Upvotes: 0
Views: 107
Reputation: 31438
The easiest way would be to create a custom selector, for example like this (drawable xml):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#33000000"/>
<item android:drawable="@android:color/transparent"/>
</selector>
and apply it to the background of ImageButton
Upvotes: 1