Java 突出的顶部应用程序栏工作不正常

Java 突出的顶部应用程序栏工作不正常,java,android,xml,Java,Android,Xml,我想实现这个动画折叠工具栏,它即使在协调器布局中也不能正常工作。 请给我解决方案,这样我就可以实现这一点 如果你还需要什么,我已经在github上上传了这个项目 以下是具有此布局的活动 package com.example.mynotes; import android.net.Uri; import android.os.Bundle; import android.widget.FrameLayout; import android.widget.TextView; import a

我想实现这个动画折叠工具栏,它即使在协调器布局中也不能正常工作。 请给我解决方案,这样我就可以实现这一点

如果你还需要什么,我已经在github上上传了这个项目

以下是具有此布局的活动

package com.example.mynotes;

import android.net.Uri;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;

import com.example.mynotes.Fragments.AllNotesFragment;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.common.SignInButton;
import com.google.android.material.button.MaterialButton;

import de.hdodenhof.circleimageview.CircleImageView;

public class GoogleSignIn extends AppCompatActivity {

    MaterialButton loginBtn, logoutBtn, btn_to_signup, goto_register;
    SignInButton GoogleLoginButton;
    TextView name , email;
    CircleImageView profilepPic;

    String GoogleName, GoogleEmail;
    Uri GooglePicUrl;

    FragmentTransaction fm;

    private GoogleSignInClient mGoogleSignInClient;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.google_sign_in_layout);
}
这是活动的布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">




    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/main_screen_topAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:liftOnScroll="true"
        android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:expandedTitleMarginStart="22dp"
            app:expandedTitleMarginEnd="28dp"
            app:expandedTitleGravity="bottom"
            app:expandedTitleTextAppearance="@style/TextAppearance.App.CollapsingToolbar.Expanded"
            app:collapsedTitleTextAppearance="@style/TextAppearance.App.CollapsingToolbar.Collapsed"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:toolbarId="@id/tool_bar">

            <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/tool_bar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/white"
                app:menu="@menu/main_screen_top_app_bar_menu"
                app:title="@string/appbarTitle"
                app:navigationIcon="@drawable/navigation_menu_icon_downloaded"
                style="@style/Widget.MaterialComponents.Toolbar.Primary"
                android:elevation="0dp"
                app:layout_collapseMode="pin" />

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


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

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">


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

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/glacier_mountain"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"/>



        </androidx.constraintlayout.widget.ConstraintLayout>


    </androidx.core.widget.NestedScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_nav_drawer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bottom_nav_bg"
        android:paddingBottom="5dp"
        app:itemIconSize="24dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:itemIconTint="@drawable/icon_tint"
        app:itemTextColor="@drawable/icon_tint"
        app:menu="@menu/bottom_nav_menu"
        android:layout_gravity="bottom"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

这就是我想要实现的目标

我遵循了Material.io上的指南

你管教程

这是安瑟尔


但是他们中没有一个能工作,请任何人给我正确的布局文件,这样我就可以完成我的项目。

经过大量研究,我自己找到了解决方案。 在我的AppTheme中,由于三个重要属性,顶部的应用程序栏在状态栏后面重叠的主要原因是正确的,这些是正确的

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
true
真的
真的
所以我把它们改成了

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:fitsSystemWindows">true</item>
true
真的
真的
您的“之前”和“之后”代码片段是相同的…:)