android - 使线性布局可滚动

标签 android

<?xml version="1.0" encoding="utf-8"?>
<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">

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

        <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">
        </TextView>
    </LinearLayout>

    <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:layout_weight="100"
        android:background="@drawable/radius"
        android:listSelector="@drawable/list_selector"
        android:paddingTop="8dip"
        android:paddingBottom="8dip" 
        android:scrollbars="none"/>

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

        <TextView style="@style/CodeFont" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content"
        android:layout_marginLeft="25dp"

        android:textSize="15dp"
        android:text="Notification Preference">
        </TextView>
    </LinearLayout>

        <ListView style="@style/listbag" android:id="@+id/settingsListView2" android:layout_width="fill_parent"
         android:layout_height="wrap_content" android:layout_weight="100"
            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"  />

</LinearLayout>

我想让 LinearLayout 可滚动,但我不知道在这里有什么用,我试过 ScrollView 但它不起作用。我只想在 LinearLayout 中而不是在 ListView 中使用滚动。我只想让 parnet 布局可滚动。你能给我一些建议吗?

最佳答案

像这样放Scrollview

<LinearLayout>
<ScrollView>
 <LinearLayout>
       Your layouts
 </LinearLayout>
 </ScrollView>
 </LinearLayout>

关于android - 使线性布局可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8295609/

相关文章:

android - 从 ADB 安装后静态 BroadcastReceiver 不工作

java - Android 应用程序在恢复时忘记登录

android - 自定义 GridView 适配器中的 TextView 不会更新,但 ImageView 会更新

java - 从用户绘制的图像中裁剪掉空白

适合所有设备的 Android 启动画面图像大小

android - 由于 : This Handler class should be static or leaks might occur,我如何编写静态处理程序

java - 二进制 XML 文件行 #29 : Binary XML file line #29: Error inflating class fragment

android - 为什么我的 ProgressBar 在不同的布局中看起来不同

android - 我如何知道 Android 设备上的 GPU 使用情况?

java - 从 JSON 对象获取数组