I have been trying to wrap my editText with ScrollView to auto scroll it when the content is updated. I found the problem that the EditText wont cover the entire scroll view even with both width and height are set to fill_parent. Please enlighten me. Thank you.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="send"
/>
<EditText
android:id="@+id/msgBox"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/sendButton"
android:gravity="left"
android:longClickable="false"
/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/msgBox">
<EditText
android:id="@+id/chatBox"
android:editable="false"
android:gravity="left|top"
android:cursorVisible="false"
android:longClickable="false"
android:clickable="false"
android:autoLink="all"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</ScrollView>
</RelativeLayout>
Try adding android:fillViewport="true"
to ScrollView properties. That should make it adjust its size every time something inside it changes. Also, use android:layout_height=wrap_content
for EditText
. It doesn't make sense to fill a parent that itself can re-size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With