Reputation: 575
I have an small ImageButton
placed on the top/right corner and a Button
behind, wrapping all the content.
I think that the normal behaviour may be that when touch the small ImageButton
, it receives the touch. But the current behaviour is that when it is touched, is like not existing, and passint the touch to the behind button.
I tried by using the android:clickable
attribute, putting the small ImageButton
in a FrameLayout
also with android:clickable="true"
, and a lot of other things.
Here is an image with the two elements selected, and the .xml. I think that it isn't really complex thing, but I don't know what i'm doing wrong.
Thank you everyone.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/club_placeholder" />
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:textColor="#fff"
android:textSize="16sp"
android:textStyle="bold"
android:layout_centerInParent="true" />
<Button
android:id="@+id/btBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_tab"
android:layout_alignLeft="@+id/ivBackground"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/ivBackground" />
<ImageButton
android:id="@+id/btFavorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_tab"
android:padding="15dp"
android:src="@drawable/ic_favorite_border_white_24dp"
android:clickable="true"
android:contentDescription="Favorite"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Upvotes: 1
Views: 138
Reputation: 156
I think that your Button has higher elevation than the ImageButton. In fact, if you set a color to your background button, you will not see the favorite imageButton. So, changing your Button to ImageButton could solve the problem.
Check this link: stackoverflow thread
I hope this could help you ;)
Upvotes: 1