在我的电话,改变imeOptions和的inputType什么都不做;设置movementMethod和/或scrollBarStyle会严重地拧紧组件,以至于用户将无法选择任何文本; isVerticalScrollBarEnabled和isHorizontalScrollBarEnabled什么都不做;我能做的最好的就是用
txt.setSingleLine(false);
(txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
似乎是不必要的),但不会显示在神该死的EditText任何滚动。最终我放弃了,并且随时需要一个多行EditText来扩充布局片段。这里的布局:
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:inputType="textMultiLine"
android:lines="4"
android:minLines="4"
android:gravity="top|start"
android:maxLines="4"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbars="vertical"
/>
而这里的安口段:
fun ViewManager.multiLineEditText(@StyleRes theme: Int = 0, init: EditText.() -> Unit): EditText = ankoView(
{ ctx -> ctx.layoutInflater.inflate(R.layout.util_multilineedittext, [email protected] as ViewGroup, false) as EditText }, theme, init)
开发在Android吸这么难。
是的先生。你说对了!它效果很好。格拉西亚斯。 – Ton 2013-05-09 19:31:12
如果调用setEms(int),则这不起作用。 – 2015-05-21 04:25:41