/ / Android tabcontent zawiera scrollview, który ukrywa zawartość za zakładkami - android, scrollview, android-tabhost

Android tabcontent zawiera scrollview, który ukrywa zawartość za zakładkami - android, scrollview, android-tabhost

Mam układ, który zawiera Tabhost. Karty znajdują się u dołu ekranu. Pierwsza karta uruchamia grupę ActivityGroup. Pierwsza aktywność w grupie ActivityGroup zawiera przewijany widok. Gdy zawartość jest wyświetlana w przewijanym widoku i przewijasz całą drogę w dół, dolna część przewijania jest ukryta za zakładkami. Wszelkie pomysły, jak to naprawić?

Kiedy uruchamiam grupę aktywności, używam tego kodu:

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

Czy wystrój prezentuje cały ekran? Chcę tylko, żeby widok był kartą. Oto główny układ:

<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>

Oto widok, który chcę w zakładce:

<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>

Odpowiedzi:

4 dla odpowiedzi № 1

Napraw swój układ tak, aby widok zawartości zmieścił się nad widżetem karty, zamiast wypełniać cały kontener nadrzędny, co oznacza, że ​​należy ułożyć go w pełnym rozmiarze RelativeLayout a następnie połóż TabWidget na szczycie. Coś bardziej w tym stylu:

<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>

Usunąłem także niektóre niepotrzebne elementy, takie jak android:orientation który nie robi nic w środku RelativeLayout.

HTH


1 dla odpowiedzi nr 2

Optymalny wynik.

android: minWidth = Zwiększ wartość ...


    <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>

1 dla odpowiedzi nr 3
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs"/>

Oto kluczowa linia,

android:layout_above="@android:id/tabs"

0 dla odpowiedzi nr 4

Wiem, że może być "poprawny" sposób, aby to zrobić, ale właśnie dodałem

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

na dole pliku xml, który ładowałem do karty.

Również użytkownik1060374 ma rację potrzeby FrameLayoutaby być powyżej Tabwidget, lub przewiń ekran ukryje (będzie na górze) pasek zakładek, jeśli zawartość wymaga przewinięcia. Ale samo zrobienie tego nie odpowie na twoje pytanie, więc dodałem dopełnienie.