Search code examples
androidlayoutandroid-edittexttitlebar

Android Title bar gets pushed up when edit text content increases


I have a relative layout which contains only the edit text view. But when content of edittext increases, my title bar gets shifted upwards. Most of the solutions I went through addresses the issue of shifting title bar when keyboard pops out. But I didn't found anything in case its content increases. I also used android:isScrollContainer="false" as suggested in this post How to avoid soft keyboard pushing up my layout?, but still the same issue. Is there a way to prevent it? Here is my xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="false" 
    android:background="@drawable/background" >

    <EditText
        android:id="@+id/hidden_edit_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:imeOptions="flagNoExtractUi"
        android:inputType="textMultiLine"
        android:singleLine="false"
        android:paddingLeft="10sp"
        android:paddingTop="5sp"
        android:paddingRight="5sp"
        android:scrollbars="vertical"
        android:background="@android:color/transparent"
        android:textSize="26sp" >
    </EditText>
</RelativeLayout>

Solution

  • I managed to solve this issue by putting edittext in scrollview and replacing adjustPan with adjustSize in the manifest. This is the final working layout

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
       android:id="@+id/rl_view"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:background="@drawable/background">
    <EditText
        android:id="@+id/hidden_edit_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:imeOptions="flagNoExtractUi"
        android:inputType="textMultiLine"
        android:paddingLeft="10sp"
        android:paddingRight="5sp"
        android:paddingTop="5sp"
        android:singleLine="false"
        android:textSize="25sp" >
    </EditText>
    </ScrollView>