Khi tôi chèn văn bản vào trường EditText
của mình, văn bản có khoảng cách bất thường giữa chính nó và dòng của EditText
. Dưới đây là một màn hình in từ thiết bị đầu cuối của tôi, nơi bạn có thể thấy khoảng cách này tôi đang nói về, nó được đánh dấu màu đỏ. EditText - Khoảng cách giữa văn bản và dòng EditText
Tôi đã chơi xung quanh với căn chỉnh văn bản và trọng lực nhưng không thành công.
Đây là 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>
Ai đó có thể nhận ra lý do tại sao điều này xảy ra và giải thích cho tôi làm thế nào tôi có thể sửa chữa nó?
--------------- EDIT -----------------------
tôi đã cập nhật mã XML mà tôi đã đăng trong câu hỏi ban đầu lên mã XML thực mà tôi đã sử dụng trong ứng dụng của mình như được yêu cầu trong nhận xét.
Các printscreen đầu tiên (một ở trên, là từ một thiết bị thực -> Galaxy S4 chạy Android 4.4.4 CyanogenMod) và đây là một printscreen từ giả lập sử dụng API 19
là đường màu xanh lục là hình ảnh tùy chỉnh không? –
Không, đó là dòng chữ 'EditText' khi bạn gõ một số văn bản vào đó. – dazito
làm việc tốt của nó trong kết thúc của tôi .. u u thêm bất kỳ mã cho nó cho allignment? –