Содержимое вкладки Android содержит прокрутку, которая скрывает содержимое за вкладками

У меня есть макет, который содержит Tabhost. Вкладки находятся внизу экрана. Первая вкладка запускает ActivityGroup. Первая активность в этой ActivityGroup содержит прокрутку. Когда содержимое отображается в прокрутке, и вы прокручиваете полностью вниз, нижняя часть прокрутки скрыта за вкладками. Любые идеи, как это исправить?

Когда я запускаю группу действий, я использую этот код:

Window window = getLocalActivityManager().startActivity(pActivityClass.getName(), intent);
setContentView(window.getDecorView());

Вид декора на весь экран? Я просто хочу, чтобы представление было вкладкой. Вот основной макет:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_alignParentTop="true"/>
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>

Вот вид, который я хочу во вкладке:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<RelativeLayout android:id="@+id/myLayout" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView android:id="@+id/title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="16sp"/>

        ... a bunch of other components ...

</RelativeLayout>
</ScrollView>

person user1060374    schedule 22.11.2011    source источник


Ответы (4)


Исправьте свой макет, чтобы представление контента помещалось над виджетом вкладки, вместо того, чтобы заполнять весь родительский контейнер, который говорит ему размещать как полный размер RelativeLayout, а затем размещать TabWidget сверху. Что-то вроде этого:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
<RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <FrameLayout
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@android:id/tabs"/>
  <TabWidget
    android:id="@android:id/tabs"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>

Я также удалил некоторые ненужные элементы, такие как android:orientation, который ничего не делает внутри RelativeLayout.

ХТН

person devunwired    schedule 22.11.2011

Оптимальный результат.

android:minWidth= Увеличьте значение...


    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

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

            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:fillViewport="true"
                android:scrollbars="none" >

            <TabWidget
                **android:minWidth="480dp"**
                android:id="@android:id/tabs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TabWidget>

            </HorizontalScrollView>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"/>
        </LinearLayout>
    </TabHost>
person ss1907    schedule 27.08.2012

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs"/>

Здесь ключевая строка,

android:layout_above="@android:id/tabs"
person DanKodi    schedule 24.01.2013

Я знаю, что может быть "правильный" способ сделать это, но я просто добавил

<LinearLayout android:layout_width="fill_parent"
        android:layout_height="50dp"></LinearLayout>

в конец XML-файла, который я загружал на вкладку.

Также user1060374 прав, FrameLayout должен быть выше Tabwidget, иначе прокрутка скроет (будет поверх) панель вкладок, если содержимое необходимо прокручивать. Но просто это не ответит на ваш вопрос, поэтому я добавил дополнение.

person Rick    schedule 26.01.2012