我需要显示大量的EditText的屏幕,其中的每一个将只允许进入0-2位数字上控制。默认的EditText大小太宽了,我在屏幕上显示足够的EditText的控制,但我一直无法弄清楚如何使它们更窄。我已经在

尝试以下属性

<强> XML:

android:maxLength="2"
android:layout_width="20dip"
android:maxWidth="20px"
android:ems="2"
android:maxEms="2"

所以,问题是:怎样可以EDITTEXT比默认可以做得更小

有帮助吗?

解决方案

尝试这种方式相反,示出了差异。使用layout_width具有指定宽度。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<EditText
    android:width="10dip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />

<EditText
    android:layout_width="40dip"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    android:maxLength="2"
    />

</LinearLayout>

“替代文字”

其他提示

嘿,一旦你试试这个,它可能工作.......  机器人:textAppearance = “机器人:ATTR / textAppearanceSmall”

在情况下,你最终此页面上搜索如何实现在Java代码中一样..

txtSample.setFilters(new InputFilter[]{new InputFilter.LengthFilter(2)});

当在表中,因为你描述,机器人:layout_gravity =“左”,将折叠的EditText向的EditText

的指定的大小
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top