这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/etTweetReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:ems="10"
android:hint="Discuss up to 140 characters"
android:imeOptions="actionDone"
android:inputType="textCapSentences"
android:lines="2"
android:maxLength="140"
android:paddingBottom="10dp"
android:singleLine="false" />
<Button
android:id="@+id/theReviewBarButton"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:text="Submit Review"
android:textSize="22sp" />
<Spinner
android:id="@+id/spinnerSort"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:scrollbars="none"
android:layout_marginRight="5dp"
android:layout_marginTop="8dp" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当EditText框到达结尾时,我希望它包装到下一行.现在,它只是继续向右移动屏幕上的所有内容.
我正在创建一个包含编辑文本的动态布局.我想让这个编辑文本可滚动.
questionEntry.setMaxLines(1);
questionEntry.setVerticalScrollBarEnabled(true);
questionEntry.setMovementMethod(new ScrollingMovementMethod());
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以滚动编辑文本.但问题是当我打字的时候.如果它到达编辑文本的末尾,它将停止键入我的文本而不会自动跳转到下一行.如果按下回车键,它将跳转.我想让它自动化.
我正在尝试EditText使用软键进行编辑时具有以下特征.我准备了文档,在这里搜索,玩参数但找不到工作配置.
EditView屏幕上的视图有几行高度(例如3-4).我可以实现{1,2,3}和{1,2,4}但不能实现{1,2,3,4}.我的理由是,由于内容是单行(没有换行符),因此不使用Enter键,因此应该能够更改为Done标签.
我的设置代码如下所示
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
editText.setHorizontallyScrolling(false);
editText.setSingleLine(false);
// This does not work. Soft keyboard has Enter action.
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
Run Code Online (Sandbox Code Playgroud)
可能吗?有什么建议吗?
这已经被问过很多次(1,2,3,4 ...),但那是很久以前,既没有答案,我现在的工作.因此发布新问题而不是碰撞旧问题.对不起,副本.
我需要一个EditText,其中:
如果您有Gmail或收件箱应用,我需要完全具有电子邮件主题字段的功能.
这是近似图片 - 只有键盘应显示>按钮,而不是插入符号按钮.
我一直在尝试各种EditText属性及其组合,包括那些android:inputType="textEmailSubject",但我总是让它单行而不是包装,或者我有这个插入按钮,它允许换行.另一个有趣的事实是,我可以使用非库存键盘(AnySoftKeyboard),但不能使用库存键盘.
请帮忙
我对此功能非常绝望.我尝试了几乎所有的东西,以使这些EditTexts多线启用,但他们只是继续在一行上滚动整个EditText.
停止在EditText边框的末尾并移动到下一行有多难?
我有一个EditText和2个按钮的活动.其中一个按钮将预定的文本行添加到EditText.另一个将EditText的文本放入某种形式的对象中,稍后我会在应用程序中使用它.
但是我不能让这个多线功能工作..我试过限制大小.设置多行标志.禁用单行.给行和minLines一个随机数(10).禁用horizontals滚动EditText.但没有任何作用......
谁能告诉我,我到底做错了什么?我怎么能解决这个可怕的EditText憎恶.
这就是我现在的噩梦.
<EditText
android:id="@+id/callofedittext"
android:layout_width="wrap_content"
android:inputType="textMultiLine"
android:width="300dp"
android:minLines="10"
android:layout_height="wrap_content"
android:gravity="top|left"
android:textColor="@color/textWhite"
android:background="@color/textBlack"
android:paddingLeft="3dp"
android:singleLine="false"
android:scrollHorizontally="false"
>
<requestFocus />
</EditText>
Run Code Online (Sandbox Code Playgroud)
它困扰着我的梦想......
编辑:>在隧道尽头的光.
当我专注于xml时..一个新的清洁项目向我指出,这EditText textMessage = (EditText)findViewById(R.id.callofedittext); textMessage.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);引起了我的所有问题.不是特别是xml中的属性.
我有这个布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin" >
<LinearLayout
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想要的是当用户输入的文本多于适合单行的文本时,EditText包装线,自动增加高度并在下一行显示不合适的文本.本EditText不应该是滚动的水平.
我读了很多与此相关的问题,但没有一个有帮助.目前EditText上面没有包装线,可以水平滚动.我在Android 4.2和4.4上测试过.
编辑:添加完整的布局.
EDIT2:
对不起,这是我的错.我在代码中以编程方式更改输入类型:
mEditText.setInputType(mInputTypes.get(question.getType()));
Run Code Online (Sandbox Code Playgroud)
所以使用这一行,我已经覆盖了xml的输入类型.我修改了代码,multiLine输入类型确实有效.
当我在 EditText 框中键入内容时,包含它的相对布局不会展开。问题是我想要它。
这是问题的直观显示:

其中大约有 5 行乱码,您可以看到倒数第二行被截断。最多应显示 5 行,但实际上并未显示,很可能是因为它们位于高度设置为包裹内容的布局内。如何在 EditText 展开时使父布局展开?
这是显示您在图片中看到的消息框的问题 xml:
<RelativeLayout
android:id="@+id/group_chat_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:background="@drawable/transparent_background2" >
<TextView
android:id="@+id/send_msg_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/transparent_background2"
android:text="Send" />
<EditText
android:id="@+id/group_chat_input_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignBottom="@id/send_msg_button"
android:layout_toLeftOf="@id/send_msg_button"
android:background="#00000000"
android:hint="Type a message..."
android:textColorHint="#EEEEEE"
android:inputType="textMultiLine"
android:maxLines="5"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:shadowColor="#000000"
android:shadowRadius="3"
android:shadowDx="3"
android:shadowDy="3"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)