Can someone help me make a Collapsable Toolbar go to the bottom without exiting from the screen?
Initial view:
After scrolling down:
This is what I've tried, but the toolbar scrolls always to the top and dissapears:
<?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:id="@+id/search_place_root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.location.SearchPlaceActivity">
<android.support.constraint.ConstraintLayout
android:id="@+id/search_place_header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/home_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/search_place_et"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="25dp"
android:layout_marginStart="57dp"
android:layout_marginTop="8dp"
android:background="#e3e3e3"
android:padding="10dp"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/search_place_back_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
app:layout_constraintBottom_toBottomOf="@+id/search_place_et"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/search_place_et"
app:srcCompat="@drawable/back" />
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_place_header"
android:foregroundGravity="bottom">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.constraint.ConstraintLayout
android:id="@+id/search_place_results_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/list_search"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="122dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/list_search">
<ImageView
android:id="@+id/imageView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:src="@drawable/location_pin"
app:layout_constraintBottom_toBottomOf="@id/search_place_use_my_current_loc_tv"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/search_place_use_my_current_loc_tv" />
<TextView
android:id="@+id/search_place_use_my_current_loc_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="22dp"
android:layout_marginTop="34dp"
android:fontFamily="@font/opensanssemibold"
android:letterSpacing="0.02"
android:lineSpacingExtra="12sp"
android:text="@string/use_my_current_location"
android:textColor="#000000"
android:textSize="15sp"
app:layout_constraintStart_toEndOf="@+id/imageView22"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.constraint.ConstraintLayout>
How can I make the transition for my whole content to go to the bottom and shrink a little bit?
Xml
<LinearLayout 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:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.androidhive.bottomsheet.MainActivity"
tools:showIn="@layout/activity_main">
<-Your Views->
</LinearLayout>
Java
BottomSheetBehavior sheetBehavior = BottomSheetBehavior.from(layoutBottomSheet);
/**
* bottom sheet state change listener
* we are changing button text when sheet changed state
* */
sheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState) {
case BottomSheetBehavior.STATE_HIDDEN:
break;
case BottomSheetBehavior.STATE_EXPANDED: {
btnBottomSheet.setText("Close Sheet");
}
break;
case BottomSheetBehavior.STATE_COLLAPSED: {
btnBottomSheet.setText("Expand Sheet");
}
break;
case BottomSheetBehavior.STATE_DRAGGING:
break;
case BottomSheetBehavior.STATE_SETTLING:
break;
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.