我有一个 MaterialAlertDialog 的布局,其中只有一个 NumberPicker
<?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 中使用的主题只是消除数字之间的分隔符的一种解决方法:
<style name="default_number_picker">
<item name="colorControlNormal">@color/color_transparent</item>
<item name="android:textStyle">bold</item>
</style>
在设备上,对话框以最大宽度出现,向左/向右填充,距设备边缘约 16dp。有谁知道如何将 MaterialAlertDialog 的宽度减小到原始宽度的 70%?现在它很空,因为它只有那些数字。