这是我的xml布局:带有ViewPager的TabLayout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@android:color/white"
android:minHeight="@dimen/standard_min_height_container"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchView"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorPrimaryDark"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget" />
<ViewPager
android:id="@+id/customViewPager"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/common_color_bg"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/tabLayout"
app:layout_constraintRight_toRightOf="@+id/tabLayout"
app:layout_constraintTop_toBottomOf="@+id/tabLayout" />
</android.support.constraint.ConstraintLayout>
Androd 5.0 +上的结果
这是Android 4.3的结果
为什么选择Androdi 4.3。右边框和scrollBar之间有差距? 我需要显示scrollBar才能正确对齐。就像在Android 5.0 +上一样
答案 0 :(得分:1)
您应该将scrollbarStyle更改为您想要的那个。
机器人:scrollbarStyle:
insideInset //Inside the padding and inset.
insideOverlay //Inside the padding and overlaid.
outsideInset //Edge of the view and inset.
outsideOverlay //Edge of the view and overlaid.
检查一下 https://developer.android.com/reference/android/view/View.html#attr_android:scrollbarStyle