Как разместить мой NestedScrollView после моего AppbarLayout - PullRequest
0 голосов
/ 28 августа 2018

Я создаю colappsingToolBar, но проблема в том, что мой NestedScrollView отображается внутри AppBarLayout вверху, а не отображается после AppBarLayout. Я также приложил код и изображение. Я видел много учебных пособий в Интернете, которые они делали таким же образом, но я не знаю, почему мой код не работает.

enter image description here

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appabr"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsimg_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/bg_member_center"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="exitUntilCollapsed|scroll"
            android:fitsSystemWindows="true">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/my_points"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="47dp"
                    android:textColor="@color/white"
                    android:id="@+id/string"

                    />


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/string"
                    android:layout_centerHorizontal="true"
                    android:text="0"
                    android:textColor="@color/white"
                    android:id="@+id/member_points"
                    android:textSize="26sp"
                    android:textStyle="bold" />


                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/graph_member_center"
                    app:layout_collapseMode="parallax"
                    android:fitsSystemWindows="true"
                    android:layout_below="@+id/toolbar"

                    tools:ignore="NotSibling" />


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="26dp"
                    android:text="Silver Member"
                    android:layout_alignParentBottom="true"
                    android:layout_centerHorizontal="true"
                    android:id="@+id/member_rank"
                    android:fontFamily="sans-serif-medium"
                    android:textColor="@color/white"
                    android:textSize="12sp"
                    android:layout_marginBottom="10dp"

                    />

                <ImageView
                    android:layout_width="23dp"
                    android:layout_height="26dp"
                    android:layout_alignParentBottom="true"
                    android:layout_centerHorizontal="true"
                    android:src="@drawable/medal"
                    android:id="@+id/user_badge"
                    android:layout_toRightOf="@+id/member_rank"
                    android:layout_marginLeft="5dp"
                    android:layout_marginBottom="10dp"
                    />


            </RelativeLayout>

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                android:id="@+id/toolbar">

                <ImageView
                    android:id="@+id/btn_back"
                    android:layout_width="27dp"
                    android:layout_height="32dp"
                    android:src="@drawable/ic_arrow_back"
                    android:tint="@color/white" />

            </android.support.v7.widget.Toolbar>




        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="adlfjsd adsf adsf dsafasd fsda f af dsaf afl djsaflk sjdafl jsalf jsdalf jsdal fjasdl fjalsd jflas jflsa djfdl"
            android:textSize="10sp"/>


    </android.support.v4.widget.NestedScrollView>

</android.support.constraint.ConstraintLayout>  

.

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.office.scrroabletoolbar"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:28.1.0'
    implementation 'com.android.support:design:28.1.0'
}


configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.1.0'
            }
        }
    }
}

1 Ответ

0 голосов
/ 28 августа 2018

Измените контейнер ConstraintLayout на CoordinatorLayout. Поведение будет влиять только на дочерние представления макетов Координатора

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...