在滚动视图中不滚动

时间:2019-03-14 08:11:26

标签: java android layout scrollview

父级是相对布局,然后在其中是图像视图和滚动视图,在滚动视图中是另一个相对布局。
在手机中进行测试时,它不会向下滚动。
请提供修复帮助。
滚动视图内的相对布局内有一些编辑文本组件和一个按钮。

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

<ImageView
android:id="@+id/reglogo"
android:layout_width="200sp"
android:layout_height="150sp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="@drawable/logo" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@id/reglogo"
android:layout_marginTop="180dp"
android:layout_marginBottom="-551dp"
android:fillViewport="true">

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

2 个答案:

答案 0 :(得分:0)

您必须使用LinearLayout来滚动视图以及wrap_content

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

<ImageView
android:id="@+id/reglogo"
android:layout_width="200sp"
android:layout_height="150sp"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="@drawable/logo" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@id/reglogo"
android:layout_marginTop="180dp"
android:layout_marginBottom="-551dp"
android:fillViewport="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
/>

答案 1 :(得分:0)

您已将子级RelativeLayout的高度设置为match parent。这意味着RelativeLayout具有与ScrollView相同的高度。因此,没有什么可滚动的,因为它们的高度相同!

相关问题