I have a relatively simple layout that contains an EditText
. The activity itself uses the dialog theme. The dialog ends up being tiny, the edit text isn't even big enough to show the initial string.
I know that tiny dialogs are a common problem (IIRC Dianne mentioned that dialogs by default use wrap_content for the parent window), and a typical workaround is to force the dialog to be a certain size in onCreate
. I prefer to fix this issue in the layout.
The idea was to give the EditText an android:minEms
of 30 to give it a reasonable size (without being ridiculously huge on a tablet), but that seems to be ignored - the EditText (and dialog) is still tiny.
Side note - the dialog's height is too small too - 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="@开发者_JAVA百科+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>
Change your RelativeLayout to android:layout_width="wrap_content"
.
精彩评论