Android макет - NestedScrollView перекрывает AppBarLayout - PullRequest
0 голосов
/ 08 марта 2020

Я новичок ie в Android и в следующем уроке от - https://appsnipp.com/free-android-profile-design-with-source-code/ для создания страницы профиля. Я преобразовал этот код в Androidx-совместимый. Но почему-то NestedScrollView перекрывает AppBarLayout .. нужна помощь, чтобы выяснить, как я могу решить эту проблему.

activity_consultant_profile. xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".activity.ConsultantDetails"
    android:background="@color/profileBackground">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay"
        tools:ignore="MissingConstraints">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/profilePrimaryDark"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleTextAppearance="@style/TransparentText">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                android:id="@+id/linearLayout"
                android:background="@drawable/profile_bk">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/profile_round" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="\@appsnippuser"
                    android:textSize="28dp"
                    android:textStyle="bold"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="developer@appsnipp.com"
                    android:textSize="12dp"
                    android:textStyle="bold"/>
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:layout_gravity="bottom"
                    android:layout_marginTop="20dp"
                    android:background="@color/profileBackground">
                    <View
                        android:layout_alignParentTop="true"
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:background="@drawable/profile_bk"/>
                    <TextView
                        android:text="Back to\nHome"
                        style="@style/profileStyledBackButton" />
                </RelativeLayout>
            </LinearLayout>

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

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

    <include layout="@layout/activity_consultant_details" />

</androidx.constraintlayout.widget.ConstraintLayout>

activity_consultant_details. xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/app_bar"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    app:behavior_overlapTop="64dp"
    tools:context=".activity.ConsultantDetails"
    tools:showIn="@layout/content_activity_consultant_profile">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp">
        <TextView
            style="@style/headerText"
            android:text="Account Info"
            android:layout_marginBottom="20dp"/>
        <RelativeLayout style="@style/profileDetailsLayout">
            <ImageView
                android:id="@+id/nameImageView"
                android:src="@drawable/ic_name"
                style="@style/profileDetailsImage" />
            <TextView
                android:id="@+id/nameTextView"
                android:text="Name"
                android:layout_toRightOf="@id/nameImageView"
                style="@style/profileDetailsTextMain" />
            <TextView
                android:id="@+id/consultantName"
                android:layout_toRightOf="@id/nameImageView"
                style="@style/profileDetailsMiniText" />
        </RelativeLayout>
        <View style="@style/proifleDetailsView" />
        <RelativeLayout style="@style/profileDetailsLayout">
            <ImageView
                android:id="@+id/mobileImageView"
                android:src="@drawable/ic_mobile"
                style="@style/profileDetailsImage" />
            <TextView
                android:text="Mobile"
                android:layout_toRightOf="@id/mobileImageView"
                style="@style/profileDetailsTextMain"/>
            <TextView
                android:text="+91-8129999999"
                android:layout_toRightOf="@id/mobileImageView"
                style="@style/profileDetailsMiniText" />
        </RelativeLayout>
        <View style="@style/proifleDetailsView" />
        <RelativeLayout style="@style/profileDetailsLayout">
            <ImageView
                android:id="@+id/emailImageView"
                android:src="@drawable/ic_email"
                style="@style/profileDetailsImage" />
            <TextView
                android:text="Email"
                android:layout_toRightOf="@id/emailImageView"
                style="@style/profileDetailsTextMain" />
            <TextView
                android:text="developer@appsnipp.com"
                android:layout_toRightOf="@id/emailImageView"
                style="@style/profileDetailsMiniText" />
        </RelativeLayout>
        <View style="@style/proifleDetailsView" />
        <RelativeLayout style="@style/profileDetailsLayout">
            <ImageView
                android:id="@+id/addressImageView"
                android:src="@drawable/ic_address"
                style="@style/profileDetailsImage" />
            <TextView
                android:text="Address"
                android:layout_toRightOf="@id/addressImageView"
                style="@style/profileDetailsTextMain" />
            <TextView
                android:text="Avenue 2nd Street NW SY."
                android:layout_toRightOf="@id/addressImageView"
                style="@style/profileDetailsMiniText" />
        </RelativeLayout>
        <View style="@style/proifleDetailsView" />
        <RelativeLayout style="@style/profileDetailsLayout">
            <ImageView
                android:id="@+id/dobImageView"
                android:src="@drawable/ic_dob"
                style="@style/profileDetailsImage" />
            <TextView
                android:text="D.O.B"
                android:layout_toRightOf="@id/dobImageView"
                style="@style/profileDetailsTextMain" />
            <TextView
                android:text="12-05-1990"
                android:layout_toRightOf="@id/dobImageView"
                style="@style/profileDetailsMiniText" />
        </RelativeLayout>
        <View style="@style/proifleDetailsView" />
    </LinearLayout>
</androidx.core.widget.NestedScrollView>

Вывод выглядит так:

enter image description here

Ожидаемый результат

enter image description here

1 Ответ

1 голос
/ 08 марта 2020

Замените макет ограничения на макет координатора, и он будет работать нормально.

...