我想填充我的TabLayout左右两侧的空间,以便它填满整个屏幕。但是我无法让它发挥作用。这是我的Layout.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="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="cytek2806northman.tabtestproject.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_height = "wrap_content"
android:layout_width = "match_parent"
>
<android.support.design.widget.TabLayout
android:layout_height = "wrap_content"
android:layout_width = "match_parent"
android:id="@+id/tabLayout"
app:tabMode="scrollable"
app:tabGravity="fill"
>
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager">
</android.support.v4.view.ViewPager>
</RelativeLayout>
答案 0 :(得分:0)
由于我无法确定相对布局中边距的值是什么,因此它必须是导致空白空间的属性。删除它们,它应该工作,因为其他任何看起来正确。
<?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="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="cytek2806northman.tabtestproject.MainActivity">
答案 1 :(得分:0)
解决方案正在删除
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"