2

BottomSheetDialogFragmentいくつかのアイテムからアイテムを選択できるようにしたい。フルスクリーンにならないようにしたいです。左上と右上の角を丸くしたい。

上記の目的のために、ItemSelectionBottomSheetDialogFragment次のように実装しました。

class ItemSelectionBottomSheetDialogFragment : BottomSheetDialogFragment() {

    ...

    override fun getTheme(): Int = R.style.ThemeOverlay_Demo_BottomSheetDialog


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) {
        ...
    }
}

fragment_item_selection.xml:

<FrameLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ItemSelectionBottomSheetDialogFragment">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/item_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

</FrameLayout>

スタイル.xml:

    <style name="ThemeOverlay.Demo.BottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/Widget.Demo.BottomSheet</item>
    </style>

    <style name="Widget.Demo.BottomSheet" parent="Widget.MaterialComponents.BottomSheet">
        <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Demo</item>
    </style>

    <style name="ShapeAppearanceOverlay.Demo" parent="">
        <item name="cornerSizeTopLeft">30dp</item>
        <item name="cornerSizeTopRight">3dp</item>
        <item name="cornerFamily">rounded</item>
    </style>

フラグメントを表示すると、丸みを帯びた角とともに下から表示されます。ただし、少し上にスワイプすると、一番下のシートのダイアログがそれ以上上がらず、上の角が丸みを帯びた形から直角の四角形にアニメーション化されます。

この問題を解決するにはどうすればよいですか?

4

0 に答える 0