1

I have a surfaceView in the background of my activity and edit text over it, i need to show edit text when virtual keyboard is shown withouth resizing surfaceView... At the end I need only edit text to move when virtual keyboard is shown

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_relative_layout">


<SurfaceView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_fragment_surfase_view"
    />

<LinearLayout
    android:id="@+id/main_fragment_bottom_menu_layout"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingTop="10dp">

    <View
        android:layout_weight="0.5"
        android:layout_width="0dp"
        android:layout_height="0dp" />

    <Button style="@style/RoundButtonMainScreenFragment" />

    <View
        android:layout_weight="0.5"
        android:layout_width="0dp"
        android:layout_height="0dp" />

    <Button style="@style/RoundButtonMainScreenFragment" />

    <View
        android:layout_weight="0.5"
        android:layout_width="0dp"
        android:layout_height="0dp" />

    <Button style="@style/RoundButtonMainScreenFragment" />

    <View
        android:layout_weight="0.5"
        android:layout_width="0dp"
        android:layout_height="0dp" />

    <ImageButton
        android:src="@android:drawable/ic_menu_camera"
        style="@style/RoundButtonMainScreenFragment"
        android:contentDescription="Delete" />

    <View
        android:layout_weight="0.5"
        android:layout_width="0dp"
        android:layout_height="0dp" />
</LinearLayout>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:id="@+id/list_view_container"
    android:layout_alignParentTop="true"
    android:isScrollContainer="true">

</FrameLayout>
    <EditText
        android:visibility="visible"
        android:id="@+id/main_screen_edit_text"
        android:alpha="0.5"
        android:layout_above="@id/main_fragment_bottom_menu_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:layout_gravity="bottom"/>
</RelativeLayout>
Jole
  • 85
  • 5

1 Answers1

0

Try adding the following line to your AndroidManifest.xml

    <activity
        android:name="YourActivityName"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:windowSoftInputMode="adjustPan" >
    </activity>

More info on it can be found here under android:windowSoftInputMode

Edson Menegatti
  • 4,006
  • 2
  • 25
  • 40
  • The Surface View moves up and my video moves up with it. I need my video to stay fixed, only Edit Text to float over virtual keyboard – Jole May 14 '15 at 19:54
  • I don't think what you want can be achieved by automatic means. You can detect the soft keyboard appeared and then move the edit text using a translation animation or settings its layout parameters. What is the motive behind preventing the video from moving up? – Edson Menegatti May 15 '15 at 12:20
  • How can this be achieved? Where this event happens? – Jole May 15 '15 at 14:10
  • You can check the onConfigurationChanged method that should be called when the soft keyboard appears. However this method will be called when rotating the screen and other events that affect UI. Also, take a look at this answer http://stackoverflow.com/questions/25216749/softkeyboard-open-and-close-listener-in-an-activity-in-android – Edson Menegatti May 15 '15 at 20:32