RecyclerView没有获得触摸事件,因为上面有另一个LinearLayout(有时候)

时间:2016-08-25 17:45:14

标签: android android-recyclerview android-touch-event

我有RecyclerView获取触摸事件。 一切正常,但是,当Visibility.Visible LinearLayoutandroid:clickable="true")高于Recyclerview,之后我将其Visibility.GonerecyclerView 1}}没有得到触摸事件。 我该怎么办?

    mTipContainer.setVisibility(View.GONE);
    mTipContainer.setClickable(false);
    mTipContainer.setOnClickListener(null);

tip_container 是有问题的布局,在RecyclerView时会触发visibility.visible触摸事件,甚至一旦显示的是visibility.gone。

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout

xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/DrawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fancy="http://schemas.android.com/apk/res-auto"
android:elevation="7dp">



<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


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

    <FrameLayout android:id="@+id/contenedor" android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>


<android.support.v7.widget.RecyclerView
    android:id="@+id/RecyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#ffffff"
    android:scrollbars="vertical">

</android.support.v7.widget.RecyclerView>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#313131"
    android:id="@+id/tip_container"
    android:visibility="gone"
    android:layout_margin="0dp"
    android:padding="0dp"

    >
    <ImageView
        android:id="@+id/tip_drawable"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerInside"
        android:src="@drawable/tip_minutos"/>
    <ImageView
        android:id="@+id/tip_close"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_marginRight="10dp"
        android:src="@drawable/cross_close"
        android:scaleType="centerInside"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:clickable="true"
        android:tint="@color/white"
        android:layout_marginTop="40dp"/>

    <mehdi.sakout.fancybuttons.FancyButton
        android:id="@+id/tip_boton_continuar"
        android:layout_width="match_parent"
        android:layout_height="55dp"

        fancy:fb_textSize="14sp"
        android:paddingBottom="8dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="8dp"
        fancy:fb_defaultColor="#00000000"
        fancy:fb_focusColor="@color/BotonVerdeFocus"
        fancy:fb_radius="0dp"
        fancy:fb_borderWidth="1dp"
        fancy:fb_borderColor="#ffffff"
        fancy:fb_text="Continuar"
        fancy:fb_textColor="@color/white"
        android:fontFamily="sans-serif"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"

        android:visibility="visible"/>



</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

尝试在文件底部添加RecyclerView标记并检查!