Android 片段中的TabLayout被活动';标题栏
我有一个带有4个选项卡的Android 片段中的TabLayout被活动';标题栏,android,android-fragments,material-design,android-tablayout,Android,Android Fragments,Material Design,Android Tablayout,我有一个带有4个选项卡的活动。TabLayout位于底部(我知道这违反了指导原则,但这就是设计)。其中一个片段也有选项卡,应该放在顶部,但它被标题栏遮住了 如何将选项卡添加到片段,使其不被工具栏遮挡 这里是activity\u layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
活动
。TabLayout
位于底部(我知道这违反了指导原则,但这就是设计)。其中一个片段
也有选项卡,应该放在顶部,但它被标题栏遮住了
如何将选项卡添加到片段
,使其不被工具栏遮挡
这里是activity\u 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>
将高程设置为0。从
AppBarLayout
设置高程非常理想,但无论如何,您可以这样做
getSupportActionBar().setElevation(0);
将高程设置为0。从
AppBarLayout
设置高程非常理想,但无论如何,您可以这样做
getSupportActionBar().setElevation(0);
删除
app:elevation=“@dimen/elevation”
。删除app:elevation=“@dimen/elevation”
。谢谢!但是,当其他片段可见时,如何返回高程?我必须在每一个中调用setElevation吗?是的。您需要为每个自定义提升行为设置提升。如果答案有帮助,请接受并投票。谢谢!但是,当其他片段可见时,如何返回高程?我必须在每一个中调用setElevation吗?是的。您需要为每个自定义提升行为设置提升。如果答案有帮助,请接受并投票。