【问题标题】:Set height for EditText no more than the coordinates of the center screen为 EditText 设置高度不超过中心屏幕的坐标
【发布时间】:2012-06-17 13:33:22
【问题描述】:

我是 Android 新手。

现在我需要EditText,它应该不超过一定的大小。现在我尝试使用这段代码:

 <EditText
        android:id="@+id/editText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:inputType="text|textMultiLine"
        android:minLines="3" />

layout_height="wrap_content" - 在这种情况下,我的 EditText 高度等于其中的字母数。

但我需要限制高度,例如为EditText 设置高度不超过中心屏幕。

我知道我们遇到了一些问题,因为 Android 使用许多不同的屏幕。

我们有办法计算这个高度吗?我的意思是EditText 的下边框不应该超过屏幕中心。

非常感谢!

【问题讨论】:

    标签: android android-edittext


    【解决方案1】:

    您可以通过添加其他值来限制 EditText

    android:maxLines
    

    你还可以添加

    android:maxHeight
    

    具有某种 dp 值。

    我不会使用其他技术来限制高度。

    【讨论】:

    • 如何以编程方式更改 maxHeight?任何想法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 2013-03-28
    • 1970-01-01
    • 2016-10-09
    相关资源
    最近更新 更多