0

I have the following layout for an activity...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical"
    android:fillViewport="true"
    android:background="#3ba4a4a4"
    android:fadeScrollbars="true">

    <TextView
        android:id="@+id/text_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textIsSelectable="false"
        android:text="@string/test_text"
        android:textSize="40sp"/>

</ScrollView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="2dp">

    <EditText
        android:id="@+id/edit_text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="@string/edit_text_hint"
        android:layout_marginTop="8dp"
        android:theme="@style/InputMethodTheme"/>

    <ImageButton
        android:id="@+id/button_send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_action_send"/>

    </LinearLayout>

When the soft keyboard is opening I want the end of the TextView to go up with the EditText... Any Idea on How to do That? The EditText is going up normally as it should but its blocking the text view

i have tried the following in the manifest file in my activity

android:windowSoftInputMode="adjustPan"

But the action bar disappears which i don't want...

UPDATE

I tried the following in the TextView

android:layout_gravity="bottom"

and it seems to react as i want it to but some of the lines before it are getting removed and extra spaces are being added after the last word...

Nayas
  • 1
  • 2

1 Answers1

0

Basically you need to listen to the keyboard opening event. More How to capture the "virtual keyboard show/hide" event in Android?

Be careful when dealing with devices with soft navigation buttons e.g., Nexus 5, you may need to take the navigation bar height into consideration.

Community
  • 1
  • 1
WenChao
  • 3,586
  • 6
  • 32
  • 46
  • I Already tried listening to the keyboard opening event and focus change events and then scrolling the scrollview manually but its not reacting the way i want it to... – Nayas May 02 '15 at 09:19