【问题标题】:Android ScrollView in RelativeLayout相对布局中的Android ScrollView
【发布时间】:2014-05-09 09:05:31
【问题描述】:

我想在这个 listview 中的 listview 和图像波纹管时拥有这个 design.header。我编写了 xml 代码。我也使用了滚动视图,但是当我适配我的数组时我的 listview 的高度不会改变。我只能显示第一项列表显示。 在我的选项问题是 xml 文件 这是一个源xml文件

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

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="fill_parent"
                android:layout_height="50dp"
                android:background="#ff0000" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="@drawable/geocell" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/relativeLayout2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@+id/relativeLayout1"
                android:orientation="vertical" >

                <ListView
                    android:id="@+id/menu_listview"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" >
                </ListView>
            </RelativeLayout>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/relativeLayout2"
                android:orientation="horizontal" >

                <ImageView
                    android:id="@+id/popapshow"
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:background="@drawable/geocell" />
            </RelativeLayout>
        </RelativeLayout>
    </ScrollView>
</LinearLayout>

【问题讨论】:

  • 我猜 scrollview 只能有一个孩子我还是不太确定这个问题!请详细说明
  • 这种布局有很多问题...最值得注意的是,您有一个ListView,高度为wrap_content,另一个ScrollView 内有一个ListView。总的来说,这种布局比它必须的要复杂得多。我看到很多多余的视图并没有真正做任何事情......
  • 如果你放 ListView ScrollView 那么你的 ListView Scroll 不起作用,所以你不能在 ScrollView 中使用 Scrollable 视图。
  • 您有什么解决方案?

标签: android android-layout android-scrollview


【解决方案1】:

从根目录中删除LinearLayout并添加ScrollView

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

【讨论】:

    【解决方案2】:

    试试这个

     <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >
    
        <RelativeLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    

    【讨论】:

    • 其实你的问题不是很清楚,无法理解你的要求,能不能说的更清楚一点?
    • 我试图理解你。我在这张图片中有一个图像和 lisview 波纹管,而且我在 listview 中也有一个图像 whitch。当我在 listview 中调整我的 arralist 时,我只能显示这个项目
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 1970-01-01
    • 2014-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多