【发布时间】:2017-05-22 03:43:24
【问题描述】:
我有一个带有 4 个标签的 Activity。 TabLayout 位于底部(我知道这违反了准则,但这就是设计)。 Fragment 之一也有标签,应该放在顶部,但它被标题栏遮住了。
如何将标签添加到Fragment,使其不被工具栏遮蔽?
这里是activity_layout.xml
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_main"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/fragments"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg_main_tabs"
app:elevation="@dimen/elevation"
app:tabIndicatorHeight="0dp"/>
</LinearLayout>
和fragment_with_tabs.xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_main"
android:orientation="vertical">
<android.support.design.widget.TabLayout
android:id="@+id/clothes_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:tabIndicatorColor="@color/colorPrimaryDark"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextColor="@android:color/white" />
<android.support.v4.view.ViewPager
android:id="@+id/clothes_fragments"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
【问题讨论】:
-
删除
app:elevation="@dimen/elevation"。
标签: android android-fragments material-design android-tablayout