我正在使用TabLayout
aViewPager
来显示我的标签名称,如下所示。
但是正如您所看到的,我的标题覆盖了我的标签。我希望我的标签靠近屏幕顶部,如下所示。
这是我的view_pager.xml
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="stellar.kade_c.com.MainActivity">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed" />
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
如何实现呢?
更改app:tabMode="fixed"
为app:tabMode="scrollable"
固定的
固定选项卡可同时显示所有选项卡,最好与可在选项卡之间快速旋转的内容一起使用。选项卡的最大数量受视图宽度的限制。固定制表符的宽度相等,基于最宽的制表符标签。
可滚动
可滚动选项卡在任何给定时刻显示选项卡的子集,并且可以包含更长的选项卡标签和更多的选项卡。当用户不需要直接比较选项卡标签时,它们最适合用于在触摸界面中浏览上下文。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句