Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Make AlertDIalog buttons a uniform size
    primarykey
    data
    text
    <p>I have an alert dialog with a positive and negative button added programatically. In the dialog layout there are also two buttons, above the AlertDialog's native buttons. </p> <p><img src="https://i.stack.imgur.com/L7Syh.png" alt="dialog"></p> <p>When these two are right next to each other, I realized that in this dialog, the native positive/negative/neutral buttons are not equally weighted. The content of their text determines their horizontal weight, rather than each taking up 50% (or 33% if 3 buttons) of the dialog. So in my case, where the negative button's text is longer than that positive button's text, we get something that looks like the image I posted above.</p> <p>I can't find a way to fix this, does anyone have an idea?</p> <p>Thanks!</p> <p>XML as requested:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:id="@+id/rcd_msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_margin="8dp" android:text="@string/rating_dialog_text" android:textSize="14dp" android:textColor="@android:color/white" android:gravity="center"/&gt; &lt;RatingBar android:id="@+id/rcd_rating_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/rcd_msg" android:layout_margin="8dp" android:paddingBottom="10dp" android:numStars="5" android:rating="0" android:layout_centerHorizontal="true"/&gt; &lt;RelativeLayout android:layout_height="56dp" android:layout_width="match_parent" android:layout_below="@id/rcd_rating_bar"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"&gt; &lt;RelativeLayout android:id="@+id/rcd_image" android:layout_width="0dp" android:layout_height="fill_parent" android:background="@color/selectable_transparent" android:layout_weight="1"&gt; &lt;TextView android:id="@+id/rcd_image_text" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerInParent="true" android:paddingLeft="0dp" android:gravity="center" android:text="@string/add_image" android:textColor="@android:color/white" android:textSize="16sp" android:clickable="true"/&gt; &lt;ImageView android:id="@+id/rcd_image_img" android:layout_height="32dp" android:layout_width="32dp" android:layout_centerVertical="true" android:layout_margin="8dp" android:layout_toLeftOf="@id/rcd_image_text" android:scaleType="centerInside" android:src="@android:drawable/ic_menu_camera"/&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:id="@+id/rcd_comment" android:layout_width="0dp" android:layout_height="fill_parent" android:background="@color/selectable_transparent" android:layout_weight="1"&gt; &lt;TextView android:id="@+id/rcd_comment_text" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerInParent="true" android:paddingRight="6dp" android:gravity="center" android:text="@string/add_comment" android:textColor="@android:color/white" android:textSize="16sp" android:clickable="true"/&gt; &lt;ImageView android:id="@+id/rcd_comment_img" android:layout_height="32dp" android:layout_width="32dp" android:layout_centerVertical="true" android:layout_margin="4dp" android:layout_toRightOf="@id/rcd_comment_text" android:scaleType="centerInside" android:src="@drawable/ic_menu_comment"/&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="1dp" android:layout_height="38dp" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:orientation="horizontal" android:layout_margin="10dp" android:background="@color/transparent_white" /&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload