【问题标题】:Adding an inputType prevents editText from re sizing添加 inputType 可防止 editText 重新调整大小
【发布时间】:2014-10-30 15:25:29
【问题描述】:

基本上将 inputType 添加到 textView 将阻止它更改行数。 即:如果没有 inputType,当您到达 editText 的末尾时,它会变大,您将继续在第二行输入,在添加 inputType 的情况下,您只需横向滚动

<EditText
    android:id="@+id/editText_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:maxLines="5"
    android:ems="10"
    android:imeOptions="actionNext"
    android:inputType="textPersonName" >

    <requestFocus />
</EditText>

那么我怎样才能同时获得 inputType 和自动调整大小?

【问题讨论】:

  • 问题出在您使用的 inputType 中。 textPersonName dosnt 允许您拥有多个 linse。使用 inputtype text 来实现这一点。
  • swing 和小姐那里的哥们,我已经尝试过了,更不用说我的 textPostalAddress 也不这样做。
  • 您使用的根布局是什么?相对布局?

标签: android android-edittext resize


【解决方案1】:

这将解决您的问题:

<EditText
    android:id="@+id/editText_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:ems="10"
    android:imeOptions="actionNext"
    android:inputType="textMultiLine"
    android:maxLines="5" >

    <requestFocus />
</EditText>

【讨论】:

  • 哇,我真的很生气,从来没有注意到作为一个选项,在我所有的 editTexts 上使用了 |textMultiLine 并且像一个魅力一样工作。干杯伙伴!
猜你喜欢
  • 1970-01-01
  • 2015-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多