【发布时间】:2015-03-01 10:01:26
【问题描述】:
我已经创建了一个应用界面材料设计工具栏、抽屉,一切正常。然后我想添加 2 个选项卡,所以我使用了https://github.com/neokree/MaterialTabs 库。现在片段和滑动操作有效。但是工具栏现在消失了,tabHost 代替了它。在 Android Studio 设计视图(不是 avd)中它显示,但是当它涉及到真实设备(kitkat)时它不是。我不知道出了什么问题我已经实现了与 lib 模块中的测试相同的方式。
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MyActivity">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/toolbar"
android:id="@+id/toolbar" />
<it.neokree.materialtabs.MaterialTabHost
android:id="@+id/tabHost"
android:layout_width="match_parent"
android:layout_height="48dp"
app:primaryColor="#009688"
app:accentColor="#2B4AE0"
android:layout_below="@+id/toolbar" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tabHost" />
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_addButtonColorNormal="@color/primary"
fab:fab_addButtonColorPressed="@color/primary_pressed"
fab:fab_addButtonPlusIconColor="@color/white"
fab:fab_labelStyle="@style/menu_labels_style"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="Event"
fab:fab_icon="@drawable/ic_attendance"
fab:fab_colorPressed="@color/white_pressed" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="Message"
fab:fab_icon="@drawable/ic_message"
fab:fab_colorPressed="@color/white_pressed" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/action_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/white"
fab:fab_title="Attendance"
fab:fab_icon="@drawable/ic_events"
fab:fab_colorPressed="@color/white_pressed" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</RelativeLayout>
</FrameLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginTop="?attr/actionBarSize"
android:background="#F8F8F8"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:fitsSystemWindows="false" />
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
-
你解决了吗?我也有同样的问题。谢谢
-
我的正在工作。但我不知道我是如何解决这个问题的。如果你愿意,我可以发布新的 xml。
-
好的,把xml贴出来,谢谢。您使用的是新版本的 it.neokree.materialtabs.MaterialTabHost 吗?
标签: android-tabs material-design android-toolbar