Я разрабатываю приложение для Android, реализующее планшет, просмотрщик и верхний боковой скользящий ящик и вкладки внизу. В приложении используется android-support-v4 FragmentPagerAdapter, который можно найти в образцах пакета поддержки v4. Ссылка можно найти здесь:
http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
Кажется, я не могу одновременно отображать как скользящий ящик, так и TabHost.
Вот мой макет. Блок com.mobicartel... - это пользовательский скользящий ящик. -------------------------------------------------- -----------------------------------------
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res/com.mobicartel.tabsandpager"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.mobicartel.tabsandpager.slidingdrawer.MultiDirectionSlidingDrawer
xmlns:my="http://schemas.android.com/apk/res/com.mobicartel.tabsandpager"
android:id="@+id/drawer"
my:direction="topToBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
my:handle="@+id/handle"
my:content="@+id/content">
<include
android:id="@id/content"
layout="@layout/pen_content" />
<ImageButton
android:id="@id/handle"
android:layout_width="wrap_content"
android:layout_height="40px"
android:src="@drawable/sliding_drawer_handle_bottom" />
</com.mobicartel.tabsandpager.slidingdrawer.MultiDirectionSlidingDrawer>
<FrameLayout
android:id="@+id/tab_host_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/drawer">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:layout_marginBottom="-4dip"/>
</LinearLayout>
</TabHost>
</FrameLayout>
Содержимое TabHost фактически не отображается. Вместо этого прослушиватель табуляции и прослушиватель просматривают друг друга, чтобы они синхронизировались. ViewPager заполняется фрагментами с помощью специального адаптера.
Есть идеи?
Кто-нибудь
Я никогда не использовал TabHost с вкладками внизу, потому что это не рекомендуется (в официальных руководствах по дизайну), однако, похоже, что вы используете найденный здесь хак: qaru.site/questions/41304/....
Я заметил, что ваш вес FrameLayout
равен 0, а также высоте и ширине. Попробуйте установить:
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_weight="1"/>
как показано в ответе.