当前位置 : 主页 > 手机开发 > android >

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

来源:互联网 收集:自由互联 发布时间:2021-06-11
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
<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>

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

我不认为将多个列表放在一个屏幕上是一个好主意becoz touch会变得很奇怪,使用屏幕会变得很复杂.你应该考虑别的东西在一个屏幕上一起显示多个列表.你可以在一个屏幕上水平排列多个列表单屏.Romain Guy(谷歌开发者)也在以下链接中接受这个事实….

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

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

网友评论