【问题标题】:android edit text design - remove edit text line bottom padding & change text and line between paddingandroid编辑文本设计-删除编辑文本行底部填充并更改填充之间的文本和行
【发布时间】:2019-02-13 02:41:08
【问题描述】:

我在 android ui 设计中遇到了一些问题。

这是一个编辑文本。 我必须删除(1)填充并更改(2)的填充大小。 (1) 是下划线和边框之间的填充, (2) 是文本和下划线之间的填充。 而目前这个editText的 android:includeFontPadding="false" 现在。

请快速回答!

【问题讨论】:

  • 创建自定义underLine Drawable。为此,您可以创建三个可绘制文件,并且可以在此可绘制文件的帮助下做任何事情。

标签: android user-interface material-design


【解决方案1】:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"   >

<EditText
    android:id="@+id/etEmail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="24dp"
    android:background="@null" // removes underline
    android:lines="1"
    app:layout_constraintEnd_toEndOf="parent"        
    />

<View
    android:id="@+id/lineTwo"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginTop="5dp"  //change this line as you need
    android:background="@android:color/white" 
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/etEmail" />

</android.support.constraint.ConstraintLayout>

【讨论】:

  • 感谢您的回答!但现在我必须使用编辑文本底线选择器。当用户在那里输入一些文本时,改变颜色。而不是我必须更改活动代码中的线条颜色?
【解决方案2】:
<EditText
        android:id="@+id/xyZ"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:lines="1" />

【讨论】:

  • 请在您的回答中添加一些解释。
  • 感谢您提供此代码 sn-p,它可能会提供一些有限的即时帮助。 proper explanation 将通过展示为什么这是解决问题的好方法,并使其对有其他类似问题的未来读者更有用,从而大大提高其长期价值。请edit您的回答添加一些解释,包括您所做的假设。
猜你喜欢
  • 2020-11-03
  • 1970-01-01
  • 2018-08-06
  • 1970-01-01
  • 2020-05-11
  • 1970-01-01
  • 2011-02-28
  • 2019-08-31
  • 1970-01-01
相关资源
最近更新 更多