Open AndroidDeveloperLB opened 6 days ago
I can't say https://github.com/material-components/material-components-android/blob/master/docs/components/BottomSheet.md is easy to understand. See layout files in the catalog app: https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/bottomsheet/res/layout/cat_bottomsheet_content.xml https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/bottomsheet/res/layout/cat_bottomsheet_scrollable_content.xml https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/bottomsheet/res/layout/cat_bottomsheet_unscrollable_content.xml ...
bottomSheetDialog.setContentView(R.layout.cat_bottomsheet_content);
View content =
LayoutInflater.from(getContext())
.inflate(R.layout.cat_bottomsheet_scrollable_content, new FrameLayout(getContext()));
bottomSheetDialog.setContentView(content);
bottomSheetDialog.setContentView(R.layout.cat_bottomsheet_unscrollable_content);
...
@manabu-nakamura Sample doesn't match the instructions. You shouldn't use new FrameLayout
for the inflater.
You should do as on the instructions:
I don't understand what you want me to check here. It seems similar to what I did, just that I didn't set a fixed size as I want the size to match the content, and if it's too large, then be able scroll.
So instead of what's on cat_bottomsheet_unscrollable_content.xml
, I can't use android:layout_height="600dp"
. A lot of empty space will be shown if I do it. Imagine a list of operations to show, yet we only have 1-2 items there...
This seems to work, but it's not working when using the one of the instructions here:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- <com.google.android.material.bottomsheet.BottomSheetDragHandleView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"/>-->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/bottom_drawer_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="200dp" android:layout_height="200dp"
android:layout_gravity="center_horizontal" android:background="#33ff0000"
android:gravity="center" android:text="Hello bottom sheet" />
<!-- <TextView-->
<!-- android:layout_width="match_parent" android:background="#ff0"-->
<!-- android:layout_height="50dp"-->
<!-- android:text="text"/>-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
So, please update the instructions and match with the samples. This time I got it bad from both of them, as the instructions weren't updated, and the samples don't match them. Both samples and instructions should be updated.
I've also removed the BottomSheetDragHandleView, but according to the instructions it's something good to add. Thing is, I can't find here any explanation of how to at least hide it when you can't collapse/expand anyway...
Description: Full description of issue here I just wanted to have some scrollable content in BottomSheetDialogFragment.
Expected behavior: Screenshots and/or description of expected behavior Fill the space of the bottom sheet, having the TextView at the top of the content.
What happens instead is that it got empty space above the TextView.
Source code: The code snippet which is causing this issue
Android API version: Android API version here 35
Material Library version: Material Android Library version you are using here (e.g., 1.1.0-alpha07) 1.13.0-alpha07
Device: Device on which the bug was encountered here Pixel 6.
My Application.zip