EditText-文本和EditText行之间的间隙 [英] EditText - Gap between text and EditText's line

查看:51
本文介绍了EditText-文本和EditText行之间的间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在EditText字段中插入文本时,文本本身与EditText的行之间存在异常间隙.这是我终端上的打印屏幕,您可以看到我在说的这个差距,它以红色标记.

When I insert text to my EditText field the text has an abnormal gap between itself and the EditText's line. Here's a printscreen from my terminal where you can see this gap I'm talking about, it is marked in red.

我一直在尝试文本对齐和重力处理,但是没有成功.

I've played around with text alignment and gravity but to no success.

这是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>

有人能发现这种情况的原因并向我解释如何解决此问题吗?

Can someone spot why this is happening and explain me how can I fix it?

---------------编辑-----------------------

我已将我在原始问题中发布的XML代码更新为我在评论中要求的应用程序上的真实XML代码.

I've updated the XML code I posted in the original question to the real XML code I've on my app as requested in a comment.

第一个打印屏幕(上面的屏幕来自真实设备->运行Android 4.4.4 CyanogenMod的Galaxy S4),这是来自使用API​​ 19的模拟器的打印屏幕

The first printscreen (the one above, is from a real device -> Galaxy S4 running Android 4.4.4 CyanogenMod) and here is a printscreen from the emulator using API 19

推荐答案

要更改EditText文本和底行之间的间距,您可以使用

To change gap between EditText text and bottom line you can use 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值.或者您可以使用android:paddingTop

Replace paddingBottom value as per your requirement. Or you can use android:paddingTop

这篇关于EditText-文本和EditText行之间的间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆