如何使EditText上比默认小? [英] How to make EditText smaller than default?

查看:129
本文介绍了如何使EditText上比默认小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to show a large number of EditText controls on a screen, each of which will only allow entering 0-2 digits. The default EditText size is too wide for me to show enough EditText controls on a screen, but I have been unable to figure out how to make them narrower. I have tried the following attributes in

XML:

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

所以,问题是:如何能比默认EDITTEXT可以做得更小。

So the question is: how can EditText be made smaller than default?

推荐答案

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

Try this way instead, shows the difference. Use the layout_width with the specified 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>

这篇关于如何使EditText上比默认小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆