Tablayout 和 Viewpager 之间的小填充
Small padding between Tablayout and Viewpager
我正在尝试找出如何删除这条白色填充线:
我的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>
我找不到问题出在哪里。谢谢!
只需从 TabLayout
中删除 android:minHeight="?actionBarSize"
<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>
我正在尝试找出如何删除这条白色填充线:
我的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>
我找不到问题出在哪里。谢谢!
只需从 TabLayout
中删除android:minHeight="?actionBarSize"
<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>