onClick for RelativeLayout未在SwipeRefreshLayout内触发

时间:2018-03-11 12:10:11

标签: android onclick android-relativelayout

我在RelativeLayout中有一个onClick方法,当用户点击屏幕上的任意位置时触发一个功能。但它没有从SwipeRefreshLayout.Below触发是代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/chat_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@null"
    tools:context=".UserChatActivity"
    android:onClick="hideIcons">

    <include
        android:id="@+id/chat_app_bar"
        layout="@layout/app_bar_layout" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@color/lightGrey"
        android:layout_below="@id/chat_app_bar">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/message_swipe_layout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_below="@id/chat_app_bar"
        android:layout_above="@+id/bottomlayout"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:background="@color/lightGrey"
        android:layout_weight="80"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >


        <ListView
            android:id="@+id/chatListView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:padding="@dimen/activity_horizontal_margin"
            android:layout_margin="@dimen/activity_horizontal_margin"
            ></ListView>



    </android.support.v4.widget.SwipeRefreshLayout>

        <LinearLayout
            android:id="@+id/share_icons_linearlayout"
            android:layout_width="0dp"
            android:layout_weight="20"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@color/lightGrey"
            android:layout_gravity="right"
            android:gravity="right"
            android:paddingRight="@dimen/activity_vertical_margin"
            android:visibility="invisible">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_action_pluscircle"
                android:tint="@color/appBackgroundColor"
                />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_action_pluscircle"
                android:tint="@color/appBackgroundColor"
                />
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_action_pluscircle"
                android:tint="@color/appBackgroundColor"
                />

        </LinearLayout>

    </LinearLayout>

它是由'share_icons_linearlayout&#39;触发的。区域。但不是来自&#39; message_swipe_layout&#39;。以及其他任何地方。

请帮忙。

1 个答案:

答案 0 :(得分:0)

RelativeLayout中添加  android:clickable="true"属性