2015-01-22 2 views
11

Когда я вставляю текст в поле EditText, текст имеет ненормальный промежуток между собой и линией EditText. Вот экран с моего терминала, где вы видите этот пробел, о котором я говорю, он отмечен красным. enter image description hereEditText - пробел между текстом и строкой EditText

Я играл с выравниванием текста и гравитацией, но безуспешно.

Вот XML:

<RelativeLayout 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" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       tools:context=".MainActivity"> 

    <TableLayout 
     android:id="@+id/startJourneyLinearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:stretchColumns="1"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <TextView 
       android:id="@+id/startLocationTxtView" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_column="0" 
       android:layout_gravity="start" 
       android:text="@string/startLocation" 
       android:gravity="center" 
       android:textAppearance="?android:attr/textAppearanceLarge"/> 

      <EditText 
       android:id="@+id/startLocation" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_column="1" 
       android:gravity = "bottom" 
       android:hint="Some text" 
       android:inputType="text"/> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_column="2" 
       android:src="@drawable/my_ic_location"/> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <TextView 
       android:id="@+id/endLocationTxtView" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:layout_column="0" 
       android:layout_gravity="start" 
       android:gravity="center" 
       android:text="@string/endLocation" 
       android:textAppearance="?android:attr/textAppearanceLarge"/> 

      <EditText 
       android:id="@+id/endLocation" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_column="1" 
       android:inputType="text"/> 
     </TableRow> 

     <Button 
      android:id="@+id/goButton" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:text="@string/go"/> 

    </TableLayout> 

</RelativeLayout> 

Может кто-то определить, почему это происходит, и объясните мне, как я могу это исправить?

--------------- EDIT -----------------------

I Я обновил XML-код, который я разместил в исходном вопросе, до реального XML-кода, который у меня есть в приложении, как это было запрошено в комментарии.

Первый PrintScreen (выше один, от реального устройства -> Galaxy S4 работает Android 4.4.4 CyanogenMod) и вот PrintScreen из эмулятора с помощью API 19

enter image description here

+0

является то, что зеленая линия является обычным образом? –

+0

Нет, это строка 'EditText', когда вы вводите текст в нее. – dazito

+0

его работая отлично в моем конце..hav u добавил какой-нибудь код для него для allignment? –

ответ

0

Try

android:layout_height="wrap_content" 

вместо

android:layout_height="match_parent" на вашем EditText.

+0

Не я, кто проигнорировал вас, но оба мои 'EditText':' android: layout_height = "match_parent" ' – dazito

0
<EditText 
    android:id="@+id/editTxt1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_column="1" 
    android:layout_gravity = "bottom" 
    android:hint="Some text" 
    android:inputType="text"/> 
+0

Это не исправить. – dazito

+0

внизу рисунка. удалите это изображение. –

+0

Это тоже не помогло. – dazito

23

Чтобы изменить разрыв между EditText текстом и нижней строкой вы можете использовать android:paddingBottom

<EditText 
     android:id="@+id/nameEditText" 
     style="@style/DarkEditText" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="@string/name" 
     android:paddingBottom="20dp"/> 

Заменить paddingBottom значения согласно вашему требованию.

Смежные вопросы