TabLayout в AppBarLayout перекрывает содержимое в CollapsingToolbarLayout - PullRequest
0 голосов
/ 21 марта 2019

У меня проблема с TabLayout. Мне нужно показать user_profile_subscribers_label_textview, user_profile_subscribes_label_textview и user_profile_rating_label_textview внизу моего AppBarLayout, но похоже, что мой TabLayout перекрывает мои TextViews. Это мой XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 
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:fitsSystemWindows="true"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/user_profile_appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<com.google.android.material.appbar.CollapsingToolbarLayout
    android:id="@+id/user_profile_collapsingtoolbarlayout"
    android:layout_width="match_parent"
    android:layout_height="265dp"
    android:fitsSystemWindows="true"
    app:contentScrim="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
        android:id="@+id/user_profile_iv_backdrop_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/user_profile_iv_user_image"
            android:layout_width="81dp"
            android:layout_height="81dp"
            android:layout_marginTop="?attr/actionBarSize"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/user_profile_nickname_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:gravity="center"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/user_profile_iv_user_image" />

        <TextView
            android:id="@+id/user_profile_rating_label_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/label_rating"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="@+id/user_profile_subscribes_label_textview" />

        <TextView
            android:id="@+id/user_profile_subscribes_label_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/label_subscribes"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toRightOf="parent"
            app:layout_constraintRight_toLeftOf="parent" />

        <TextView
            android:id="@+id/user_profile_subscribers_label_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/label_subscribers"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toRightOf="@+id/user_profile_subscribes_label_textview"
            app:layout_constraintRight_toRightOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/user_profile_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</com.google.android.material.appbar.CollapsingToolbarLayout>

<com.google.android.material.tabs.TabLayout
    android:id="@+id/user_profile_tablayout"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:tabGravity="fill"
    app:tabMode="fixed" />

</com.google.android.material.appbar.AppBarLayout>

    <androidx.viewpager.widget.ViewPager
    android:id="@+id/user_profile_vp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/user_profile_fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="16dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

И это результат на устройстве: результат

image

Итак, я добавил это в мои TextViews

android:layout_marginBottom="18dp"

И увидел это: результат с marginBottom

image

Может кто-нибудь объяснить, как это работает и как это исправить?

...