Android Scrollview不会滚动

时间:2017-10-29 02:49:51

标签: android scrollview

我正在尝试制作scrollView的整个视图,但scrollView不会滚动。

请帮帮我:)。

这是我的xml代码:

<?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="wrap_content"
    android:scrollbars="vertical"
   >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingTop="40dp"
    android:padding="20dp"
    android:background="@android:color/white"
    android:id="@+id/mainlayout"
    >

 ////some content here

 </LinearLayout>

 </ScrollView>

2 个答案:

答案 0 :(得分:1)

更改您的ScrollView android:layout_height以匹配父级。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical">

答案 1 :(得分:0)

将滚动视图更改为android.support.v4.widget.NestedScrollView,并将height属性设置为match_parent

相关问题