在Tablayout和Viewpager之间有少量的填充物。

问题描述 投票:0回答:1

我想知道如何删除这条白色的填充线。enter image description here

我的 activity:

<LinearLayout
    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"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".activity.ShowUI">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/show_ui_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/AppTheme"
        app:layout_constraintTop_toTopOf="parent"
        app:titleTextColor="@android:color/white" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/show_ui_tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?actionBarSize"
        app:tabGravity="fill"
        app:tabIndicatorColor="@android:color/black"
        app:tabIndicatorHeight="2dp"
        app:tabBackground="@color/colorPrimary"
        app:tabMode="fixed">
    </com.google.android.material.tabs.TabLayout>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/show_ui_viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </androidx.viewpager.widget.ViewPager>

</LinearLayout>

我找不到问题出在哪里。谢谢你!我想知道如何删除这行白色填充物:我的活动:我的活动

android android-layout android-viewpager android-tablayout
1个回答
1
投票

只要删除 android:minHeight="?actionBarSize" 从TabLayout

<LinearLayout
    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"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".activity.ShowUI">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/show_ui_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/AppTheme"
        app:layout_constraintTop_toTopOf="parent"
        app:titleTextColor="@android:color/white" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/show_ui_tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabIndicatorColor="@android:color/black"
        app:tabIndicatorHeight="2dp"
        app:tabBackground="@color/colorPrimary"
        app:tabMode="fixed">
    </com.google.android.material.tabs.TabLayout>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/show_ui_viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </androidx.viewpager.widget.ViewPager>

</LinearLayout>

或者,你也可以将TabLayout的高度设置为 "actionBarSize",而不是像这样指定为minHeight。

<LinearLayout
        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"
        android:orientation="vertical"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context=".activity.ShowUI">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/show_ui_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:theme="@style/AppTheme"
            app:layout_constraintTop_toTopOf="parent"
            app:titleTextColor="@android:color/white" />

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/show_ui_tabLayout"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:tabGravity="fill"
            app:tabIndicatorColor="@android:color/black"
            app:tabIndicatorHeight="2dp"
            app:tabBackground="@color/colorPrimary"
            app:tabMode="fixed">
        </com.google.android.material.tabs.TabLayout>

        <androidx.viewpager.widget.ViewPager
            android:id="@+id/show_ui_viewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        </androidx.viewpager.widget.ViewPager>

    </LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.