I want to change the design of the dialogue, specifically the buttons.

Now it looks like this

enter image description here

I want to make the buttons easier for something like this

enter image description here

Now in my dialogue I use my XML markup and there are just buttons in it.

As far as I understand, I need to use ordinary TextView and put separators between them, which I think should be done in the form of a normal View just set them to 1dp height and backgraung desired color ...

But I am not sure that this is the smoothest solution in the first place, and secondly, how to set the length of these dividers (bars between the buttons). If you put much_parent then the bar will stretch the dialog box itself until it hits the screen, if you make a wrap_content then it just doesn’t take anything ...

I'm not sure that I explained well what I want so ask if you need to add something)

Thank)

    2 answers 2

    The best way to add dividers:

    • 1) Shove three buttons in a horizontal orientation in LinearLayout
    • 2) LinearLayout set properties:

        android:divider="@drawable/my_divider" android:showDividers="middle" 
    • 3) Create a drawable @ drawable / my_divider resource for the separator:

       <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <size android:width="1dp" /> <solid android:color="@android:color/black"/> </shape> 

      Look at the material disign better. All you need is to use it when creating the AlertDialog dialog from appcompat v7. Dialogues in the style of material design

       import android.support.v7.app.AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Dialog"); builder.setMessage("r ...."); builder.show(); 

      And three buttons can be done like this.

       builder.setButton(AlertDialog.BUTTON_POSITIVE, "Button 1 Text", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... } }); builder.setButton(AlertDialog.BUTTON_NEGATIVE, "Button 2 Text", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... }}); builder.setButton(AlertDialog.BUTTON_NEUTRAL, "Button 3 Text", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //... }});