1
我有一个小的ImageButton
放在上面/右上角和Button
后面,包装所有的内容。ImageButton在按钮触摸
我认为正常的行为可能是当触摸小ImageButton
时,它会收到触摸。但目前的行为是,当它被触摸时,就像不存在,并将触摸传递给后面的按钮。
我尝试使用android:clickable
属性,把ImageButton
的小也android:clickable="true"
,还有很多其他的东西。
这是一个图像,选择了两个元素和.xml。我认为这不是很复杂的事情,但我不知道我做错了什么。
谢谢大家。
<?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>
是,海拔是解决方案。我添加了'android:elevation =“1dp”'和'android:elevation =“2dp”'并解决了错误的行为。 但是,它在棒棒糖设备中效果不错吗? Android Studio不会给我任何错误。 – emmgfx