2

たとえば、アプリケーションに Compose LazyColumn コードを含む MyBottomSheetDialogFragment があります。

class MyBottomSheetDialogFragment : BottomSheetDialogFragment() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        return ComposeView(requireContext()).apply {
            setContent {
                Column(horizontalAlignment = Alignment.CenterHorizontally) {
                    Text("Header", color = Color.Black)
                    LazyColumn(
                        Modifier
                            .weight(1f)
                            .fillMaxWidth()) {
                        items(100) {
                            Text("Item $it", Modifier.fillMaxWidth(), Color.Black)
                        }
                    }
                }
            }
        }
    }
}

そして、次のコードを使用して表示します。

MyBottomSheetDialogFragment().show(activity.supportFragmentManager, null)

それが私たちが持っているものです:

MyBottomSheetDialogFragment 画面イメージ.jpg

ここで、LazyColumn リストを下にスクロールするとすべて正常に機能しますが、LazyColumn リストを上にスクロールすると、LazyColumn リストの代わりにボトム シート ダイアログがスクロールします。

BottomSheetDialogFragment内にLazyColumnを適切に実装するには?

XML RecyclerView リストを使用したとき、この問題を修正するために、ここで説明されているように、RecyclerView リストを NestedScrollView でラップする必要がありましたが、Jetpack Compose で修正する方法は?

4

1 に答える 1