ScrollView всегда расширяется на весь экран - PullRequest
0 голосов
/ 12 марта 2012

Друзья, у меня есть LinearLayout, который содержит 3 LinearLayout.1. Заголовок Linearlayout 2. Содержимое LinearLayout 3. Нижний колонтитул LinearLayout

2. Содержимое LinearLayout динамически получает свое содержимое во время выполнения.Много TextViews добавляется.Поэтому этот макет должен быть ScrollView.

Проблема в моем случае заключается в том, что весь экран постоянно прокручивается, а не только макет 2. Содержимое LinearLayout.

В Xml также есть SlidingDrawer, который содержит карту, если это может быть причиной проблемы.

Спасибо за поддержку, вот часть моего кода:

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical">

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:layout_marginTop="1dp"
        android:orientation="horizontal" android:weightSum="50">

        <ImageButton android:id="@+id/1"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="10" android:src="@drawable/appiconone" />

        <TextView android:id="@+id/1"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="10"  />

        <TextView android:id="@+id/2"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="10" android:text="" />

        <TextView android:id="@+id/4"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="10" android:text="" />

        <ImageButton android:id="@+id/5"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="10" android:src="@drawable/appiconone" />
    </LinearLayout>

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

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/LL2Content"
            android:layout_width="match_parent" android:layout_height="match_parent"
            android:orientation="vertical">

        </LinearLayout>

    </ScrollView>

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:layout_marginTop="20dp"
        android:orientation="horizontal" android:weightSum="100">

        <Button android:id="@+id/10"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="50" android:text="" />

        <Button android:id="@+id/11"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_weight="50" android:text="" />


    </LinearLayout>
</LinearLayout>

Ответы [ 2 ]

0 голосов
/ 12 марта 2012

Шаг 1. Используйте относительную компоновку для поддержки макета верхнего и нижнего колонтитула, а также содержимого
Шаг 2: Создайте макеты верхнего и нижнего колонтитула и включите их в основной макет, чтобы верхний и нижний колонтитулы можно было повторно использовать.
Шаг 3: Поместите область содержимого под заголовком и над макетом нижнего колонтитула.
Шаг 4:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true">
0 голосов
/ 12 марта 2012

просто измените свое исправление ScrollView Height, как это, а также добавьте fillViewport в ScrollView

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="370dp" android:fillViewport="true">

Надеюсь, это будет работать для вас ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...