Fix scrolling in bottom sheet for groups

This commit is contained in:
Praveen Kumar 2024-04-15 11:34:16 +05:30 committed by Alexander Bakker
parent 9b96bbde54
commit 9c07b981d4
2 changed files with 48 additions and 21 deletions

View File

@ -20,6 +20,8 @@ import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.ItemTouchHelper;
@ -49,6 +51,7 @@ import com.bumptech.glide.ListPreloader;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
import com.bumptech.glide.util.ViewPreloadSizeProvider;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.chip.Chip;
@ -505,6 +508,12 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
private void initializeGroupChip() {
View view = getLayoutInflater().inflate(R.layout.dialog_select_groups, null);
BottomSheetDialog dialog = new BottomSheetDialog(requireContext());
NestedScrollView scrollView = view.findViewById(R.id.scrollView);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) scrollView.getLayoutParams();
layoutParams.matchConstraintMaxHeight = getResources().getConfiguration().screenHeightDp;
dialog.getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
dialog.getBehavior().setSkipCollapsed(false);
dialog.setContentView(view);
ChipGroup chipGroup = view.findViewById(R.id.groupChipGroup);

View File

@ -1,50 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="wrap_content">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:id="@+id/drag_handle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/groups"
android:textSize="20sp" />
android:textSize="20sp"
app:layout_constraintTop_toBottomOf="@+id/drag_handle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="150dp"
android:orientation="vertical"
android:layout_marginTop="15dp">
android:layout_height="0dp"
android:minWidth="150dp"
app:layout_constraintHeight_default="wrap"
app:layout_constraintTop_toBottomOf="@+id/text_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.chip.ChipGroup
android:id="@+id/groupChipGroup"
android:paddingStart="8dp"
android:paddingEnd="8dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
android:layout_height="wrap_content"
android:minHeight="150dp"
android:orientation="vertical">
<com.google.android.material.chip.ChipGroup
android:id="@+id/groupChipGroup"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_gravity="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/scrollView"
app:layout_constraintEnd_toEndOf="parent"
android:orientation="horizontal">
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/save"
app:rippleColor="@color/dialog_button_ripple_color"
style="@style/Widget.Material3.Button.TextButton" />
<Button
@ -52,8 +71,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clear"
app:rippleColor="@color/dialog_button_ripple_color"
style="@style/Widget.Material3.Button.TextButton" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>