Android: minEms ignored in dialog actions

I have a relatively simple layout containing EditText. The work itself uses the theme of dialogue. The dialog ends with a tiny one, the edit text is not even large enough to show the start line.

I know that tiny dialogs are a common problem (IIRC Dianne mentioned that dialogs use wrap_content for the parent window by default), and a typical workaround is to force the dialog to be sized at onCreate. I prefer to fix this problem in the layout.

The idea was to give EditText a android:minEmsof 30 to give it a reasonable size (without the ridicule on the tablet), but that seems to be ignored - EditText (and the dialog) is still tiny.

Side note - the height of the dialog is too small - the button at the bottom is half the size it should be.

Layout, for reference:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView android:id="@+id/TextView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/title"
        android:gravity="center"
    />
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        >
    <ImageButton
        android:id="@+id/file_manager"
        android:src="@drawable/ic_launcher_folder_small"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:onClick="pickFile"
      />
      <EditText android:id="@+id/file"
            android:text="@string/default_file"
            android:inputType="text"
            android:minEms="30"
            android:layout_toLeftOf="@+id/file_manager"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
        />
    </RelativeLayout>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/action"
        android:onClick="performAction"
        android:text="@string/action">
    </Button>
</LinearLayout>
+3
source share
1 answer

Change RelativeLayout to android:layout_width="wrap_content".

+3
source

Source: https://habr.com/ru/post/1790393/


All Articles