2015-01-22 25 views
11

Wenn ich Text in mein EditText Feld einfüge, hat der Text eine abnormale Lücke zwischen sich und der EditText Zeile. Hier ist ein Ausdruck von meinem Terminal aus, wo Sie diese Lücke sehen können, über die ich spreche, sie ist rot markiert. EditText - Abstand zwischen Text und EditText-Zeile

Ich habe mit Textausrichtung und Schwerkraft herum gespielt, aber ohne Erfolg.

Hier ist der 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> 

Kann jemand erkennen, warum dies geschieht und mir erklären, wie kann ich es beheben?

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

I habe den XML-Code, den ich in der ursprünglichen Frage gepostet habe, auf den echten XML-Code aktualisiert, den ich in meiner App habe, wie in einem Kommentar gefordert.

Das erste Print (die oben, von einem realen Gerät ist -> Galaxy S4 Android 4.4.4 CyanogenMod läuft) und hier ist ein Printscreen aus dem Emulator API 19

enter image description here

+0

ist diese grüne Linie ein benutzerdefiniertes Bild? –

+0

Nein, es ist die 'EditText'-Zeile, wenn Sie Text eingeben. – dazito

+0

funktioniert es gut in meinem Ende..hav Sie einen Code für die Ausrichtung hinzugefügt? –

Antwort

0

Versuchen Sie es mit

android:layout_height="wrap_content" 

statt

android:layout_height="match_parent" auf Ihrem EditText.

+0

Nicht ich, wer Sie downvoted aber beide meine 'EditText' sind' 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

Es hat es nicht behoben. – dazito

+0

im unteren Bereich des Edittext-Bildes. entfernen Sie das Bild. –

+0

Es hat auch nicht geholfen. – dazito

23

Um Lücke zwischen EditText Text zu ändern und unteren Zeile Sie 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"/> 

ersetzen paddingBottom Wert wie pro Ihre Anforderung verwenden können.