小编Sor*_*tfi的帖子

BottomSheetDialogFragment 没有出现

我已经按照本教程在我的 android 应用程序中实现了 BottomSheetDiogFragment。

这是我的底部工作表布局(bottom_sheet.xml):

<?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"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<RadioGroup
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="16dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <RadioButton
        android:id="@+id/rb1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_weight="1"
        android:text="@string/rb1" />

    <RadioButton
        android:id="@+id/rb2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_weight="1"
        android:text="@string/rb2" />

</RadioGroup>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

BottomSheetDialogFragment 类:

class BottomSheetTaskRepeat : BottomSheetDialogFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.bottom_sheet, container, false)
    }
}
Run Code Online (Sandbox Code Playgroud)

活动:

private val bottomSheetTaskRepeat = BottomSheetTaskRepeat()

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    bottomSheetTaskRepeat.show(supportFragmentManager, …
Run Code Online (Sandbox Code Playgroud)

android kotlin bottom-sheet

5
推荐指数
1
解决办法
1834
查看次数

标签 统计

android ×1

bottom-sheet ×1

kotlin ×1