gpt4 book ai didi

android - EditText - 文本和 EditText 行之间的间隙

转载 作者:可可西里 更新时间:2023-11-01 19:10:02 31 4
gpt4 key购买 nike

当我将文本插入到我的 EditText 字段时,文本本身与 EditText 的行之间存在异常间隙。这是我终端的打印屏幕,您可以在其中看到我正在谈论的这个差距,它被标记为红色。 enter image description here

我试过文本对齐和引力但没有成功。

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

有人可以找出发生这种情况的原因并向我解释如何解决它吗?

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

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

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

enter image description here

最佳答案

要更改 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 值。或者你可以使用 android:paddingTop

关于android - EditText - 文本和 EditText 行之间的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28081704/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com