NumberPickerだけが含まれるMaterialAlertDialogのレイアウトがあります
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<NumberPicker
android:id="@+id/number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/default_number_picker"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
NumberPicker 内で使用されるテーマは、Numbers の間の仕切りを閉じるための単なる回避策です。
<style name="default_number_picker">
<item name="colorControlNormal">@color/color_transparent</item>
<item name="android:textStyle">bold</item>
</style>
デバイスでは、Dialog は最大幅で表示され、デバイスの端まで約 16 dp の左右にパディングがあります。MaterialAlertDialog の幅を元の幅の 70% に減らす方法を知っている人はいますか? それらの番号が入っているだけなので、今はかなり空です。