I have an activity with style Dialog, containing two EditTexts. However, only the first one is shown when I run the app. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip" >
<EditText
android:id="@+id/firstEditText"
android:layout_height="wrap_content"
android:lines="1"
android:inputType="number"
android:scrollHorizontally="false"
android:layout_width="fill_parent"/>
<EditText
android:id="@+id/secondEditText"
android:layout_height="wrap_content"
android:lines="3"
android:scrollHorizontally="false"
android:layout_width="fill_parent"/>
</LinearLayout>
As far as I know, this is normal Android behavior, but how can I make the activity show both fields without writing Java code and using only XML?
The second
EditTextdoesn’t appear because the parentLinearLayouthas the default orientation(horizontal) and the firstEditTexthas the width set tofill_parent. This will push the secondEditTextout of the screen. You either set the orientation of theLinearLayouttoverticalto show theEditTextone below the other or you setwrap_contentas the width for the firstEditTextand uselayout_weight(on bothEditText) to set up a desired ration between the first and secondEditText.