The text in my dialog is too long, and it mixes with buttons. So I figured out I should change the size of the dialog.
upd.: To make it clear, the question is if it's possible to change the size of the alert dialog in such way so that these changes apply to a layout, and how? If it is really impossible, why and what are the alternatives.
Here is how I am trying to do it in my code, according to answers in this topic:
int matchParent = WindowManager.LayoutParams.MATCH_PARENT;
rulesDialog.show();
rulesDialog.getWindow().setLayout(matchParent, matchParent);
And I got this, it just adds the white gap:
Also tried this. That didn't work at all. I also tried to add this line with the same approach, did nothing:
<item name="android:layout_height">match_parent</item>
Here is xml code of a layout passed to the AlertDialog.Builder
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/beige">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="4dp"
android:layout_margin="4dp"
android:textColor="@color/brown"
android:textSize="14sp"
android:text="@string/info_text"
android:id="@+id/info_text"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/info_text"
android:layout_centerHorizontal="true"
android:text="@string/ok"
android:padding="4dp"
android:textSize="14sp"
android:textColor="@color/orange"
android:background="@color/blank"
android:minHeight="0dp"
android:minWidth="0dp"
android:layout_margin="4dp"
android:id="@+id/ok"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/info_text"
android:layout_toEndOf="@id/ok"
android:text="@string/renew_record"
android:padding="4dp"
android:textSize="14sp"
android:textColor="@color/orange"
android:background="@color/blank"
android:minWidth="0dp"
android:minHeight="0dp"
android:layout_margin="4dp"
android:id="@+id/renew_record"/>
</RelativeLayout>
upd.: I've found that this code works:
rulesDialog.show();
int matchParent = WindowManager.LayoutParams.MATCH_PARENT;
rulesDialog.getWindow().setLayout(matchParent, matchParent);
rulesDialog.setContentView(R.layout.info);
Solves the white gap problem totally.
For some case, the problem with overlapping still exists. As far as I understand, that's a common problem for RelativeLayout
, now I am investigating it.
upd.: Yes, I should've deleted android:layout_centerVertical="true"
line from the TextView
. Now all works fine with two latter fixes, problem solved.