gpt4 book ai didi

android - 水平 ScrollView 中的回收器 View 在 android oreo 中不起作用,但在以下版本中运行良好

转载 作者:太空狗 更新时间:2023-10-29 13:03:31 25 4
gpt4 key购买 nike

以下代码不适用于 oreo 版本的 android,但适用于其他版本。在这种情况下,我正在尝试使用水平 ScrollView ,用户必须能够发表评论,而其他评论是在回收者 View 的帮助下显示的。所以我在这段代码中遇到的问题仅适用于新版本的 android。有人可以建议我吗关于这个问题的想法。这是代码

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="200dp"
android:layout_height="175dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp"
android:background="@layout/button_background"
android:layout_marginTop="15dp"
>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userfbpic1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="10dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="15dp"
android:src="@drawable/bg"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/current_username"
android:text="@string/current_username_forcomment"
android:layout_marginTop="12dp"
android:layout_marginStart="50dp"
android:textStyle="bold"
android:textColor="@color/background"
android:textSize="15sp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="60dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/background"
android:id="@+id/comments"
android:textSize="15sp"
android:hint="comment here"
android:imeOptions="actionDone"
android:singleLine="true"
android:textStyle="bold"
android:background="@android:color/transparent"
/>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_comments"
android:layout_width="wrap_content"
android:nestedScrollingEnabled="false"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</HorizontalScrollView>

最佳答案

将下面的代码添加到您在 recyclerview 上的触摸监听器中

recyclerview.addOnItemTouchListener (new RecyclerView.OnItemTouchListener() 
{
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {

int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
rv.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return false;
}

});

关于android - 水平 ScrollView 中的回收器 View 在 android oreo 中不起作用,但在以下版本中运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52145575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com