简体   繁体   中英

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM