0

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.

Lars
  • 794
  • 7
  • 21
  • Carefully sizing dialogs is often a pain, most of the time you have to do it manually. Maybe this question will help you: [How to make an alert dialog fill 90% of screen size?](https://stackoverflow.com/questions/2306503/how-to-make-an-alert-dialog-fill-90-of-screen-size). – Nicolas Oct 22 '20 at 13:45
  • i dont think its worth if you need programmatically tricks. I could convince my product owner aswell :D thanks for your advice! – Lars Oct 27 '20 at 07:30

0 Answers0