Android Custom Keyboard not resizing the window Issue

786 views Asked by At

Hi i am following this link for implementing CustomKeyboard. Everything was perfect except if there are number of EditTexts in my layout. The window is not resizing when the keyboard appears, say if i am trying to enter data to EditTexts which are placed on bottom gets covered by the keyboard. The solutions like adjust resize and adjust pan with the manifest are not working in this case, also i tried with putting ScrollView in layout, but not getting any solution. Please see my layout given below.

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >

  <EditText
    android:id="@+id/edittext0"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />

<EditText
    android:id="@+id/edittext1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext0"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/txt"
    android:inputType="text" />

<EditText
    android:id="@+id/edittext2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext1"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/txt"
    android:inputType="text" />

<EditText
    android:id="@+id/edittext3"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext2"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />

<EditText
    android:id="@+id/edittext5"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext3"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />


 <EditText
    android:id="@+id/edittext6"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext5"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />

  <EditText
    android:id="@+id/edittext7"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext6"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />

   <EditText
    android:id="@+id/edittext8"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/edittext7"
    android:layout_centerHorizontal="true"
    android:drawableRight="@drawable/hex"
    android:inputType="text" />



<!-- NOTE No need to develop a system service for keyboard, there is a standard View for that (well, not completely standard, its in a funny package 'android.inputmethodservice'. -->
<!-- NOTE The graphical layout does not know the package ('java.lang.NoClassDefFoundError: Could not initialize class android.inputmethodservice.KeyboardView') so the keyboard is not shown. -->
<!-- <android.inputmethodservice.KeyboardView
    android:id="@+id/keyboardview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:visibility="gone" 
    android:background="@drawable/normal"/>
 -->
<nl.fampennings.keyboard.CustomKeyboardView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
     android:id="@+id/keyboardview"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:visibility="gone" 
   android:keyBackground="@drawable/samplekeybackground"/>

Please help me with a solution. Thank you.

1

There are 1 answers

0
Sunny On BEST ANSWER

OK I got the solution. Please find the modified layout code.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
          android:layout_weight="1" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/edittext0"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext0"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/txt"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext1"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/txt"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext3"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext2"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext5"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext3"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext6"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext5"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext7"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext6"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />

            <EditText
                android:id="@+id/edittext8"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/edittext7"
                android:layout_centerHorizontal="true"
                android:drawableRight="@drawable/hex"
                android:inputType="text" />
        </LinearLayout>
    </ScrollView>

    <nl.fampennings.keyboard.CustomKeyboardView
        android:id="@+id/keyboardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:keyBackground="@drawable/samplekeybackground"
        android:visibility="gone" />
</LinearLayout>

</RelativeLayout>

Add a linearLayout as the child of main parent layout; Add a scroll View to that layout with weight 1 and add another layout to the scrollView as the container for child items like EditTexts and all. The keyboard view should be added in the same layout as the scrollView contains. I hope the solution will be helpful for someone.