当前位置: 首页 > 知识库问答 >
问题:

对recycleview触控事件没有连锁反应

诸葛砚
2023-03-14

我已经使用RecycleView实现了抽屉菜单,但是当我点击项目时,没有显示涟漪效果。我的设备正在运行API 22。

片段导航。xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/white">


<RelativeLayout
        android:id="@+id/nav_header_container"
        android:layout_width="match_parent"
        android:layout_height="140dp"
        android:layout_alignParentTop="true"
        android:background="@color/colorPrimary">

    <ImageView
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:src="@drawable/ic_profile"
            android:scaleType="fitCenter"
            android:layout_centerInParent="true" />

</RelativeLayout>


<android.support.v7.widget.RecyclerView
        android:id="@+id/drawerList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/nav_header_container"
        android:layout_marginTop="15dp" />


        </RelativeLayout>

我的行是:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="true">
<ImageView android:layout_width="wrap_content"    android:layout_height="wrap_content"
           android:scaleType="fitCenter"
        android:src="@android:drawable/ic_input_get" android:id="@+id/imageView"/>
<TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="30dp"
        android:paddingTop="10dp"
        android:text="asa"
        android:paddingBottom="10dp"
        android:textSize="15dp"
        android:textStyle="bold"
        android:layout_alignParentTop="true" android:layout_toRightOf="@+id/imageView"
        android:layout_toEndOf="@+id/imageView"/>

    </RelativeLayout>

问题是什么,我该如何解决?

共有1个答案

吕华彩
2023-03-14

试试这个作为你的行布局

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?android:attr/selectableItemBackground"
                android:focusable="true"
                android:clickable="true">

 <ImageView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitCenter"
    android:src="@android:drawable/ic_input_get"
    android:id="@+id/imageView"/>

 <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="30dp"
            android:paddingTop="10dp"
            android:text="asa"
            android:paddingBottom="10dp"
            android:textSize="15dp"
            android:textStyle="bold"
            android:layout_toRightOf="@+id/imageView"
            android:layout_alignParentTop="true"  
            android:layout_toEndOf="@+id/imageView"/>

        </RelativeLayout>
 类似资料:
  • 在JavaScript中,我按住两个键,并且被完美触发。当我释放其中一个键时,被触发。到目前为止一切都很好。但是我仍然按住一个键,那么为什么没有被触发呢?我需要在我的游戏中发生这种情况。我做错了什么吗?这是预期的反应吗?有什么解决办法吗?

  • 我正在为Minecraft服务器的discord制作一个机器人。我在下面有一个on_会员加入事件和on_消息事件。on_member_join工作得很好,但是当我在discord服务器中发送消息时,on_message事件内部不会发生任何事情。这是我的代码,如果有人有可能的解决方案,我会非常感激。

  • 问题内容: 由于Main.storyboard不提供Xcode,如何以编程方式添加UIView touchbegin动作或touchend动作? 问题答案: 您将不得不通过代码添加它。试试这个:

  • 让我们考虑以下脚本: 运行脚本后,bash进入循环,但可以中断(通过按Ctrl-C或发出kill-2命令)或终止(通过发出kill命令)。一切都很好。但是现在让我们考虑另一个脚本: 运行此脚本后,bash进程不再对SIGINT或SIGTERM信号作出反应。当然,它会对按下Ctrl-C或终止睡眠进程作出反应,但我感兴趣的是,使bash进程本身对这些信号作出反应。我需要这个,因为我正在用bash脚本作

  • 使用mui.trigger()方法可以动态触发特定DOM元素上的事件。 .trigger( element , event , data ) element Type: Element 触发事件的DOM元素 event Type: String 事件名字,例如:'tap'、'swipeleft' data Type: Object 需要传递给事件的业务参数 示例 自动触发按钮的点击事件: var

  • 触摸操作概述 浏览器的触摸 API 由三个部分组成。 Touch:一个触摸点 TouchList:多个触摸点的集合 TouchEvent:触摸引发的事件实例 Touch接口的实例对象用来表示触摸点(一根手指或者一根触摸笔),包括位置、大小、形状、压力、目标元素等属性。有时,触摸动作由多个触摸点(多根手指)组成,多个触摸点的集合由TouchList接口的实例对象表示。TouchEvent接口的实例对