HorizonatalScrollView на TabWidged "крадет" пространство - PullRequest
1 голос
/ 02 сентября 2011

У меня есть TabActivity с пользовательскими TabWidgets внизу.Я хочу иметь возможность добавить более 5 вкладок.В отличие от панели меню, которая динамически добавляет кнопку «еще», вкладки просто меняются и выглядят ужасно.Поэтому моей первой попыткой было обернуть мои TabWidgets в HorizontalScrollView.Проблема в том, что у меня есть ListView как TabContent, и его последний элемент, кажется, скрыт за моими TabWidgets.Это макет для моего TabView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/main_linlay_parent"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <TabHost 
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
      android:id="@+id/main_tablinear"
      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_alignParentTop="true"
        android:layout_above="@android:id/tabs"/>
      <HorizontalScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none"
        android:layout_alignParentBottom="true">
        <TabWidget
          android:id="@android:id/tabs"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_gravity="center"/>
      </HorizontalScrollView>
    </RelativeLayout>
  </TabHost>
</LinearLayout>

Я что-то не так делаю в своем макете?Есть ли лучшие способы применения более 4 вкладок?Хотя я могу видеть 4 вкладки хорошими с моим Nexus-S, я думаю, что они уже безобразны на Wildfire.Любая идея оценена

Ответы [ 2 ]

0 голосов
/ 05 сентября 2011

Я решил свою проблему сам! Я думаю, что это может быть полезно для других пользователей, чтобы увидеть решение:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/main_linlay_parent"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <TabHost 
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
      android:id="@+id/main_tablinear"
      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_alignParentTop="true"
        android:layout_above="@android:id/tabs"
        android:layout_marginBottom="50dip"/>
        <!-- note: margin bottom 50 dip above: 
           its exactly the size of my custom TabWidget  -->
      <HorizontalScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none"
        android:layout_alignParentBottom="true">
        <TabWidget
          android:id="@android:id/tabs"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_gravity="center"/>
      </HorizontalScrollView>
    </RelativeLayout>
  </TabHost>
</LinearLayout>
0 голосов
/ 02 сентября 2011

Попробуй это.У меня это сработало:

Код:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TabHost android:layout_weight="1" 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="wrap_content"
            android:layout_height="wrap_content">
            <LinearLayout android:layout_height="fill_parent"
                android:orientation="horizontal" android:layout_width="fill_parent">
                <TabWidget android:layout_height="wrap_content"
                    android:id="@android:id/tabs" android:isScrollContainer="true"
                    android:layout_width="fill_parent" android:scrollbars="horizontal"></TabWidget>
            </LinearLayout>
        </HorizontalScrollView>
        <FrameLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:id="@android:id/tabcontent">
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:id="@+id/tab1"></LinearLayout>
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:id="@+id/tab2"></LinearLayout>
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:id="@+id/tab3"></LinearLayout>
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:id="@+id/tab4"></LinearLayout>
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:id="@+id/tab5"></LinearLayout>
        </FrameLayout>
    </LinearLayout>
</TabHost></LinearLayout>
...