Home > Mobile >  Why after took a photo my toolbar and my collapsing not functioning properly like this enter image d
Why after took a photo my toolbar and my collapsing not functioning properly like this enter image d

Time:11-17

Why after took a photo my toolbar and my collapsing not functioning properly like this enter image description here please help masters...

CodePudding user response:

my code for methode collaps like this

private void checkCollapse(){

    binding.appbar.addOnOffsetChangedListener(new AppBarStateChangedListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            if (state.name().equalsIgnoreCase("COLLAPSED") || state.name().equalsIgnoreCase("IDLE")){
                binding.tvToolbartitle.setText("Add Photo Jaminan");
                backgroundStatusBar(state.name());
                binding.btnBack.setVisibility(View.VISIBLE);
                binding.btnBack.setOnClickListener(new View.OnClickListener() {


                    @Override
                    public void onClick(View view) {
                        onBackPressed();
                    }
                });
            }
            else {
                backgroundStatusBar(state.name());
                binding.tvToolbartitle.setText("");
            }
        }
    });
}

CodePudding user response:

and my xml like this

<com.google.android.material.appbar.AppBarLayout
    android:id="@ id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:background="@color/colorBackgroundTransparent"
    android:theme="@style/AppTheme.AppBarOverlay">

<com.google.android.material.appbar.CollapsingToolbarLayout
    android:id="@ id/collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="400dp"
    app:contentScrim="@drawable/round_primary02"
    app:expandedTitleMarginStart="48dp"
    app:expandedTitleMarginEnd="64dp"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

<androidx.appcompat.widget.Toolbar
    android:id="@ id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/toolbar_height_default"
    app:layout_scrollFlags="scroll|enterAlways"
    app:layout_collapseMode="pin"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

    <ImageView
        android:id="@ id/btn_back"
        android:visibility="gone"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="8dp"
        android:src="@drawable/ic_leftarrowsquare"/>

    <TextView
        android:id="@ id/tv_toolbartitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="@color/colorWhite"
        android:textSize="18sp"
        android:fontFamily="@font/manrope_b"
        android:elevation="4dp"
        android:layout_marginRight="16dp"/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>


<include android:id="@ id/toolbar_reguler" layout="@layout/toolbar_regular_new" />
<include android:id="@ id/loading" layout="@layout/loading" />

<androidx.core.widget.NestedScrollView
    android:id="@ id/nested_scv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    app:behavior_overlapTop="200dp"
    app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
  • Related