Reduce width of MaterialAlertDialog with NumberPicker

164 Views Asked by At

i have a layout for a MaterialAlertDialog that just has a NumberPicker in it

<?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>

The used theme inside the NumberPicker is just a workarround to dismiss the divider between the Numbers:

<style name="default_number_picker">
   <item name="colorControlNormal">@color/color_transparent</item>
   <item name="android:textStyle">bold</item>
</style>

On the device the Dialog appears at maximum width with a padding left / right with about 16dp to the edge of the device. Has anyone an idea how you could reduce the width of the MaterialAlertDialog to 70% for example of the origin width? Right now its pretty empty because it just has those Number in it.

0

There are 0 best solutions below