Anurag
Anurag

Reputation: 1531

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>

Upvotes: 1

Views: 1306

Answers (4)

Anurag
Anurag

Reputation: 1531

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>

Upvotes: 1

Leon Lucardie
Leon Lucardie

Reputation: 9740

Usually this can be solved by adding the android:windowSoftInputMode="adjustPan" property to your activity in the AndroidManifest file.

Upvotes: 0

Java Crazy
Java Crazy

Reputation: 57

make your relative layout height and width to wrap_content.......... probably works. since when text increases your complete layout shifts. Try it and please rpy

Upvotes: 0

hRb
hRb

Reputation: 61

try to run your code after removing :

android:background="@android:color/transparent"

Upvotes: 0

Related Questions