Android 当滚动视图作为父布局时,滚动视图不滚动
我在ScrollView中有一个相对的Yout。但滚动视图作为父布局时不会滚动Android 当滚动视图作为父布局时,滚动视图不滚动,android,android-relativelayout,android-scrollview,Android,Android Relativelayout,Android Scrollview,我在ScrollView中有一个相对的Yout。但滚动视图作为父布局时不会滚动 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:fillViewport="true" android:layout_height="matc
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_about_background"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/stack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_about_background"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
</RelativeLayout>
</ScrollView>
编辑:我从片段中删除了
rootView.setOnTouchListener
,并且ScrollView
工作正常您可以做以下几件事:
fill\u parent
,而不是match\u parent
,并对相对布局执行相同的操作希望对您有所帮助。您可以做以下几件事:
fill\u parent
,而不是match\u parent
,并对相对布局执行相同的操作<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:fillViewport="false"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_about_background"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/stack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_about_background"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
尝试使用
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:fillViewport="false"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_about_background"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/stack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_about_background"
android:paddingLeft="10dp"
android:paddingRight="10dp"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
试试这个,希望它能帮助你
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_about_background"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/stack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_about_background"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
</RelativeLayout>
</LinearLayout>
试试这个,希望它能帮助你
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_about_background"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@drawable/stack" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_about_background"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
</RelativeLayout>
</LinearLayout>
我已将图像的高度大小更改为350dp,并将文本大小设置为50sp,以了解您发布的代码是否有效。您的代码非常好,但是您必须在scrollview中添加更多视图,或者增加textview的图像大小/字体大小(如上面的代码所示)。
我已将图像的高度大小更改为350dp,并将文本大小设置为50sp,以了解您发布的代码是否有效。您的代码非常好,但是您必须在scrollview中添加更多视图,或者增加textview的图像/字体大小(如上面的代码所示)。scrollview的结尾在哪里?@Harshit Trivedi在复制时错过了这一行。问题:updated@IntelliJAmiya我知道如果ScrollView放进一个RelativeLayout里面会有用的。但是有没有其他的解决办法。设置高度以匹配父项。!你的scrollview终端在哪里?@Harshit Trivedi在复制时错过了那一行。问题:updated@IntelliJAmiya我知道如果ScrollView放进一个RelativeLayout里面会有用的。但是有没有其他的解决办法。设置高度以匹配父项。!我在TextView上尝试了一个大文本,它不是滚动我在TextView上尝试了一个大文本,它不是滚动scrolling@Ameer设置RelativeLayout
android:layout\u height=“match\u parent”
My RelativeLayout height为match\u parent。我尝试在另一个布局中滚动视图。信息技术works@Ameer添加Scrollviewandroid:orientation=“vertical”android:fillViewport=“false”
尝试使用android:fillViewport=“false”。但仍然没有滚动我找到了解决办法。我从我的应用程序中删除了rootView.setOnTouchListenerfragment@Ameer设置RelativeLayoutandroid:layout\u height=“match\u parent”
My RelativeLayout height为match\u parent。我尝试在另一个布局中滚动视图。信息技术works@Ameer添加Scrollviewandroid:orientation=“vertical”android:fillViewport=“false”
尝试使用android:fillViewport=“false”。但仍然没有滚动我找到了解决办法。我从片段中删除了rootView.setOnTouchListener