xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.chuangzheng.zhinengjujiaping.MainActivity"
android:weightSum="1">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="80sp"
android:layout_weight="0.10"
android:weightSum="1"
android:id="@+id/linearLayout">
</LinearLayout>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton_main_addgoods"
android:layout_marginRight="107dp"
android:layout_marginEnd="107dp"
android:src="@drawable/edit"
android:background="#ffffff"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="71dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/fragment_main"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@+id/linearLayout"></RelativeLayout>
布局代码是上面这样的整体布局是相对布局,然后里面有个相对布局用来放fragment fragment是一个griedview ,放fragment的相对布局一个imgebutton重叠 Imagebutton位置在右下角 现在问题是 点击Imagebutton不响应优先响应fragment中的item点击事件,如何点击优先响应imagebutton
问题解决了 我把主布局里放fragment的布局单写了一个布局文件 然后在主布局里面include 原来的Imagebutton 换成了floating action button 现在点击先响应按钮而不是先响应fragment里griedview的点击事件了
你这问题描述的太模糊了,是imagebutton在item里面还是什么?
imagebutton 设置 android:clickable="true"试试
建议使用framelayout试试,这样把imagebutton放在最顶层并添加点击事件
建议把总的布局拿出来,才能看出问题!
虽然描述的很模糊。。。你可以试试在item的根布局加android:descendantFocusability="blocksDescendants" 这个试试