I have a EditText and if I type some text it will expand to the second line if the Text is too long.
So far so good.
But if I hide the keyboard the EditText converts to a SingeLine and without scrolling behaviour.
What's going on here?
<EditText
android:id="@+id/etNote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:fontFamily="sans-serif-light"
android:inputType="textCapSentences|textMultiLine"
android:lines="2"
android:scrollbars="vertical"
android:maxLines="3"
android:textColor="@color/white"
android:textColorHint="@color/background"
android:textSize="25sp"
/>
On typing with keyboard open:
After keyboard hide:
Full XML:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1"
android:background="@color/app_color">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:minHeight="@dimen/list_item_height">
<ImageView
android:layout_height="wrap_content"
android:layout_width="72dp"
android:src="@drawable/ic_action_misc_light_24dp"
android:visibility="invisible"
/>
<EditText
android:id="@+id/etNote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:inputType="textMultiLine"
android:lines="2"
android:maxLines="3"
android:textColor="@color/white"
android:textColorHint="@color/background"
/>
</TableRow>
</TableLayout>
</merge>
I think I found the problem. In the main XML where the merge happens I have added by mistake an +id who was already there in another include layout with merge.
I removed that and now it works as it should. Really strange that I get no error about the doubled +id's!
Old code:
<!-- Note -->
<include layout="@layout/inc_reminder_note" android:id="+id/areaDate"/>
<!-- Date and Time -->
<include layout="@layout/inc_reminder_date_time"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginRight="16dp"/>
New code:
<!-- Note -->
<include layout="@layout/inc_reminder_note" />
<!-- Date and Time -->
<include layout="@layout/inc_reminder_date_time"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginRight="16dp"/>
The layout " inc_reminder_date_time " had also as id " areaDate ".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.