当前位置: 动力学知识库 > 问答 > 编程问答 >

Misplaced text in EditText android

问题描述:

Hi I have an EditText for entering the mail id as below. As I type in the characters, its not visible as show in the screen shot, the letters get shifted slightly upwards.

Here is the Username layout

 <LinearLayout

android:id="@+id/LayoutUsername "

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_weight=".50"

android:gravity="center"

android:orientation="vertical" >

<LinearLayout

android:id="@+id/LayoutUsernameText"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight=".60"

android:gravity="center"

android:orientation="horizontal" >

<TextView

android:id="@+id/usernameImage"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center|left"

android:paddingLeft="5dp"

android:text="Username :"

android:textColor="#FFFFFF"

android:textSize="26dp"

android:textStyle="bold" />

</LinearLayout>

<LinearLayout

android:id="@+id/LayoutEditUser"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight=".40"

android:background="@drawable/mailedittextbg"

android:orientation="horizontal"

android:paddingLeft="5dp"

android:paddingRight="5dp" >

<EditText

android:id="@+id/mailusername"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:clickable="true"

android:cursorVisible="true"

android:focusable="true"

android:focusableInTouchMode="true"

android:gravity="center_vertical|left"

android:hint="[email protected]"

android:imeOptions="actionDone"

android:inputType="textEmailAddress"

android:singleLine="true"

android:textColor="#000000"

android:textColorHint="#000000"

android:textSize="24sp" />

</LinearLayout>

I am not sure where I am going wrong. Please suggest how do I correct it?

网友答案:

use

 android:gravity="center_vertical|left"

for EditText

  <EditText
      android:layout_height="wrap_content"
      android:gravity="center_vertical|left"
      android:textSize="18sp" />

and use wrap_content for EditText height and use smaller text size as possible as.

网友答案:

Your Layouts that contains EditTexts have gravity = 0.4, and layouts that contains TextViews have gravity = 0.6 . Try to change this values.

分享给朋友:
您可能感兴趣的文章:
随机阅读: