gpt4 book ai didi

android - NestedScrollView 内的 NestedScrollView 不滚动

转载 作者:行者123 更新时间:2023-12-05 06:30:42 25 4
gpt4 key购买 nike

我知道这个问题很多,但我尝试了几乎所有的解决方案,即使是神奇的解决方案显然对我不起作用!:(父级是 NestedScrollview,在子级中还有另一个嵌套 ScrollView )

    parent.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event) {
Log.v(TAG,"PARENT TOUCH");
child.getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});

child.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event)
{
Log.v(TAG,"CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});

在 Logcat 上,我得到“PARENT TOUCH”和“CHILD TOUCH”,但 Chidl 不滚动!奇怪的是这个解决方案和其他解决方案适用于其他人而不是我

这是我的 xml 结构:(PS:我很想尝试您的解决方案)(编辑后

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<NestedScrollView
android:layout_width="match_parent"
android:id="@+id/parentscrollview"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">


<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:text="txt" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="txt2"
android:textSize="15sp"
android:layout_below="@+id/textView"
android:id="@+id/textView2"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text=""
android:textSize="15sp"
android:layout_below="@+id/textView2"
android:id="@+id/textView4"
/>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="@+id/textView4"
android:id="@+id/autocainatiner"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:textSize="15sp"
android:layout_marginTop="20dp"
android:textAllCaps="true"
android:text="Please Add/chose the observed clinical features :"
/>

<com.mycardboarddreams.autocompletebubbletext.MultiSelectEditText
android:id="@+id/auto_text_complete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textStyle="bold"
android:padding="5dp"
android:background="#FFEEEEEE"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">


<Button
android:id="@+id/btnPlanet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:onClick="blahblah"
android:text="Enter" />
</RelativeLayout>


</LinearLayout>

<NestedScrollView
android:layout_width="match_parent"
android:id="@+id/scrollframe"
android:layout_below="@+id/autocainatiner"
android:fillViewport="true"
android:layout_height="200dp">
<FrameLayout
android:id="@+id/auto_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"/>
</NestedScrollView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/scrollframe"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:textSize="16sp"
android:textAllCaps="true"
android:textStyle="bold"
android:gravity="center_horizontal"
android:text="Suggested Diganosi list (Please Click on suggested diseases for more infos)"
android:id="@+id/textView3"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="Suggested Diganosi list (Please Click on suggested diseases for more infos)"
android:layout_marginTop="25dp"
android:textAllCaps="true"
android:id="@+id/diagnosis"
/>

<FrameLayout
android:id="@+id/auto_list_container2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="gone"
android:background="@color/colorPrimaryDark"/>

</LinearLayout>


</RelativeLayout>
</NestedScrollView>

</RelativeLayout>

最佳答案

通过创建解决它:

public class NoInterceptScrollView extends ScrollView {

public NoInterceptScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}

}

并将其用作父类..并将两个 nestedscrollview 更改为 scrollview + 我删除了禁用父触摸的代码...

关于android - NestedScrollView 内的 NestedScrollView 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52139495/

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