是否有可能有一个 EditText,其中文本区域的高度是多行,但文本实际上只是换行文本,但禁止输入新行。我能想到的唯一解决方案是允许用户输入新行,但在按键时或输入文本后仅用空格替换新行字符。这是我所拥有的:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:minLines="3"
android:textSize="24sp" />
最佳答案
这就是我在 Rideshare 应用程序中使用的,效果很好。我的目标 SDK 是 17 (Android 4.0.3)。
<EditText
android:inputType="text|textMultiLine|textCapSentences"
android:layout_margin="1dp"
android:gravity="top"
android:background="#FFEBCD"
android:textSize="26sp"
android:id="@+id/offer_notes"
android:padding="10dp"
android:textColor="#000"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="5sp"
android:hint="Notes, e.g. $10 per passenger, leaving early morning 7AM from Bay and Yonge intersection, no smoking or pets, please. Chevy Venture, very comfortable.">
</EditText>
关于android - 多行换行的 EditText(无换行符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15084043/