android - 如何在不使用 Scrollview 的情况下使 LinearLayout 可滚动

标签 android

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/bag" 
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:orientation="vertical" >

<RelativeLayout
        android:id="@+id/relativeLayout2"
            style="@style/relbag"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView style="@style/CodeFont" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="18dp"
        android:textSize="15dp"
        android:text="General Preference"
        android:id="@+id/genpref">
        </TextView>


    <ListView
        android:id="@+id/settingsListView1"
        style="@style/listbag"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dip"
        android:layout_marginRight="15dip"

        android:background="@drawable/radius"
        android:listSelector="@drawable/list_selector"
        android:paddingTop="8dip"
        android:paddingBottom="8dip" 
        android:scrollbars="none"
        android:layout_below="@id/genpref"/>

        <TextView style="@style/CodeFont" 
        android:id="@+id/notpref"
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="25dp"
        android:textSize="15dp"
        android:text="Notification Preference"
        android:layout_below="@id/settingsListView1">
        </TextView>


        <ListView style="@style/listbag" android:id="@+id/settingsListView2" android:layout_width="fill_parent"
         android:layout_height="fill_parent"
            android:layout_marginLeft="15dip" android:layout_marginRight="15dip" 
              android:layout_marginBottom="15dip" 
        android:background="@drawable/radius" 
                android:paddingLeft="5dip" android:paddingRight="5dip" 
            android:paddingTop="15dip" android:paddingBottom="15dip" 
            android:listSelector="@drawable/list_selector" 
            android:layout_below="@id/notpref" 
            android:scrollbars="none"
            />
            </RelativeLayout>
</LinearLayout>

enter image description here

在我的应用程序中,我想在 linearlayout 中创建两个 ListView ,并使 linearlayout 可滚动而不使用 ScrollView。据我所知,scrollview 在使用 listview 时存在问题。这张图片不是我想要的,但让我们假装在 ListView 下方有另一个 ListView 。所以我想显示 ListView 的所有可用项目(在我的应用程序 2 ListView 的项目中)并使 LinearLayout 可滚动。 ScrollView 运行不正常,因为它必须只有一个直接子级。我找不到解决方案。所以请帮我解决,谢谢

最佳答案

我认为将多个列表放在一个屏幕中不是一个好主意,因为触摸会变得很奇怪并且使用屏幕会变得复杂。您应该考虑其他方法将多个列表一起显示在一个屏幕中。您可以水平排列多个在单个屏幕中列出。Romain Guy(Google 开发人员)也在以下链接中接受了这一事实....

http://groups.google.com/group/android-developers/browse_thread/thread/77acd4e54120b777

我希望这个答案能帮助你解决你的问题。

关于android - 如何在不使用 Scrollview 的情况下使 LinearLayout 可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8306679/

相关文章:

java - 在方法/函数中使用类变量会创建对源的引用而不是重复它?

android - 三星设备上的 Proguard "Missing type parameter"

Android 检查线程的连接

java - Android,SHA1 Base64 哈希并发布来自 WebView 的数据

android - 如何在 gradle 任务中检索库版本

Android 为什么操作系统会发出 onPause()

android - 通过Kotlin使用Intent Extras获取房间数据

android - Jetifier 不转换支持依赖

android - 在根项目上找不到属性 “VERSION NAME”?

android - 字符串包含引号时出现 SQL 异常(无法识别的标记)