【问题标题】:Android Scrollview doesn't show up all the contentAndroid Scrollview 不显示所有内容
【发布时间】:2015-06-29 08:20:16
【问题描述】:

我正在尝试显示列表视图并在页面中向下滚动它们。但是,滚动不会显示所有内容,仅像 30dp 一样滚动,并且要显示更多的列表视图。关于这个有很多问题,但它们不适用于我的代码。如果您能告诉我我在下面的代码中缺少什么,我将不胜感激。谢谢

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scrollView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="false">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="183dp"
        tools:context=".MainActivity"
        android:weightSum="1"
        android:id="@+id/rel">

        <android.support.v4.view.ViewPager
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/pager"
            android:layout_width="fill_parent"
            android:layout_height="171dp"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="0dp"
            android:layout_alignParentBottom="true">
        </android.support.v4.view.ViewPager>
    </RelativeLayout>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="wrap_content"
        android:layout_height="479dp"
        tools:context=".MainActivity"
        android:weightSum="1"
        android:id="@+id/rel2"
        android:gravity="left|right">

        <ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/listView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignWithParentIfMissing="false" />

    </RelativeLayout>


</LinearLayout>

【问题讨论】:

  • 不是答案,但要避免在垂直滚动的滚动视图中添加垂直滚动的 Listview
  • 还将 LinearLayout 设为 android:layout_height="wrap_content"

标签: android layout scrollview


【解决方案1】:

您应该永远不要ListView 放在ScrollView 中。这可能并且可能会导致列表视图出现不滚动等不良行为。

【讨论】:

  • 否则可以,那我怎么让它滚动呢
  • 您可以在列表视图中添加标题或将布局一分为二。但这取决于您尝试实现的目标。
  • 我需要整个页面向下滚动
  • 所以您的布局中应该可能只有一个 ListView。并在您的适配器中修改getView 方法,以便第一个视图是您想要的顶部。
  • 说真的,这是应该的吗?
猜你喜欢
  • 1970-01-01
  • 2017-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多