Act*_*ine 7 android android-layout android-edittext
我浪费了最后一小时试图弄清楚如何在一个简单的EditText中摆脱这个填充:

我想要的只是将输入与其他内容对齐,就像美丽的设计指南所说的那样.
布局不可能更简单:
<ScrollView 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"
tools:context="com.actinarium.tiomantas.SetupChallengeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_challenge_name"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/new_challenge_name_hint1"
android:singleLine="false"/>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我尝试将EditText上的填充设置为0dp - 文本已移位但行保持原样.奇怪的是,我找不到关于这个问题的任何信息,好像没有人注意到.
我认为该行是EditText的背景图像,因此更改填充不会影响它.如果需要,可以创建没有填充的自定义背景drawable.
你可以做的另一个黑客是为EditText添加一个负余量:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-4dp"
android:hint="@string/new_challenge_name_hint1"
android:singleLine="false"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2656 次 |
| 最近记录: |