I know there are lots of related questions in Stackoverflow, but I tried to do everything that's written in any of them and so far I couldn't get this working.
My problem is simple. I have an android application, and I have a box where the user will input text. However, I don't want this text to be multiline (it shouldn't have "\n" in it), but I want it to wrap if the size of the line is greater than the viewport. So basically, what I want is the same behaviour that the textBox on Gmail Subject field has.
This is my whole view:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/question"
android:textAppearance="@style/titleFont"/>
<EditText
android:id="@+id/edit_question_value"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:gravity="top"
android:inputType="textImeMultiLine|textEmailSubject"
android:maxLength="70"
>
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/answer"
android:textAppearance="@style/titleFont"/>
<EditText
android:id="@+id/edit_question_answer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="top"
android:layout_weight="0.7"
android:inputType="textMultiLine"/>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<Button
android:id="@+id/save_question"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:text="@string/save"/>
<Button
android:id="@+id/cancel_edit_question"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/cancel"/>
</LinearLayout>
The text I want to have this behaviour is theone with the id equals to @+id/edit_question_value. So far, I have been able to either make it truly multiline (so the user can type enter if he wants) or single-line and the text won't wrap. Perhaps some of the elements around the text are having some interference, and that's why I included the whole view.
Does anyone knows what is happening?