PeakGen
PeakGen

Reputation: 23035

Alignment issue in Android EditText

Please have a look at the following code

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Form" >

    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

       <TextView
           android:id="@+id/heightLabel"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="@string/height"
           /> 

       <EditText 
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_toRightOf="@+id/heightLabel"
           android:layout_marginLeft="5dp"
           android:hint=""
           />

    </RelativeLayout>


</ScrollView>

I need this EditText to be displayed right next to the TextView, with it's appropriate size. But instead, it is displaying in no where. I don't even see it! Please help!

Upvotes: 1

Views: 152

Answers (1)

Sam
Sam

Reputation: 86958

You are using wrap_content but no default text. So if the EditText is visible, it will be quite small. You need to define an appropriate size yourself. Try using match_parent as the width or adding an attribute like minWidth or ems.

Upvotes: 1

Related Questions