【问题标题】:EditText does not show its full layoutEditText 不显示其完整布局
【发布时间】:2016-05-10 06:01:00
【问题描述】:

我有以下 EditText 。

          <EditText
            android:id="@+id/editText7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10" />

对于这个edittext,我有以下布局。

但我想得到如下编辑文本:

如何获取上面的edittext?

【问题讨论】:

标签: android android-edittext


【解决方案1】:

创建一个可绘制的background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@android:color/very_light_grey"/>
    <stroke android:width="1dp" android:color="@color/grey"/>
</shape>

将编辑文本更改为

<EditText
  android:background="@drawable/background"
  android:layout_width="match_parent"
  android:paddingLeft="60dp"
  android:layout_height="wrap_content"/>

【讨论】:

  • 错误:找不到与给定名称匹配的资源(在 'color' 处,值为 '@android:color/very_light_grey')。
  • 将名为 your_background_color 的颜色添加到您的 colors.xml 文件中,并将其更改为 @colors/your_background_color。
【解决方案2】:

您可以在编辑文本中设置填充。

android:padding="10dp"

【讨论】:

    【解决方案3】:

    它基本上适用于设备的 android 版本。早期版本的 android EditText 与您寻找的外观有些相似。但是最新的你会得到线。我想建议去更改编辑文本主题或背景以满足您的目的。

    【讨论】:

      【解决方案4】:

      在xml中设置edittext的背景

      android:background="Your Color Code"
      

      【讨论】:

        猜你喜欢
        • 2016-10-29
        • 2014-11-14
        • 1970-01-01
        • 1970-01-01
        • 2017-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多