【发布时间】:2017-08-28 03:41:25
【问题描述】:
我目前使用 Drawer Layout 和 TabLayout 进行活动,就像 this image 上的活动一样。但是,我在实际显示选项卡标题时遇到问题,可以在here 上看到。虽然我仍然可以向左或向右滑动以更改可见选项卡,但选项卡栏标题不会出现。
这是活动的 .xml 布局(供您参考,我在活动文件中使用 AppCompatActivity 进行此布局):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:background="@android:color/white">
<android.support.v7.widget.Toolbar
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The Main Content View -->
<android.support.design.widget.TabLayout
android:id="@+id/request_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
android:background="@color/colorPrimary" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
<!-- The Left Navigation Drawer -->
<ListView
android:id="@+id/leftDrawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#818181"
android:dividerHeight="2dp"
android:background="#E3F2FD" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
我对xml进行了一些修改,似乎无法显示选项卡标题的原因是因为我将TabLayout放在了DrawerLayout中。但是,将 DrawerLayout 放在 TabLayout 之外会使每个标签页的内容都不会出现。
有什么方法可以同时使用 DrawerLayout 和 TabLayout 并让 tab 标题栏出现?
【问题讨论】:
标签: android android-layout xamarin.android android-appcompat drawerlayout