I am working on an application where I need a custom keyboard. Custom means not customizing the keys but I need to show different layouts inside the keyboard itself. I am attaching an image of what I am looking for please guide me how can I achieve this.
            Asked
            
        
        
            Active
            
        
            Viewed 292 times
        
    -4
            
            
        - 
                    Lots of examples of soft keyboards you can modify in the GitHub [AnySoftKeyboard](https://github.com/AnySoftKeyboard/AnySoftKeyboard), [AndroidCustomKeyboard](https://github.com/blackcj/AndroidCustomKeyboard) ... – Jon Goodwin Feb 28 '18 at 10:05
- 
                    Possible duplicate of [How to make an Android custom keyboard?](https://stackoverflow.com/questions/9577304/how-to-make-an-android-custom-keyboard) – Safiyya Feb 28 '18 at 10:14
- 
                    @JonGoodwin I wanted to put fragments and custom layouts ion the keyboard itself. – Ujjwal Bansal Feb 28 '18 at 10:21
- 
                    Thanks, Jon and Safiyya. – Ujjwal Bansal Feb 28 '18 at 11:06
1 Answers
1
            
            
        Finally, I found the solution, earlier I was making the mistake to make keyboard as a parent layout now I redesign my XML to this
<?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="wrap_content">
    <android.inputmethodservice.KeyboardView
        android:id="@+id/keyboard1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:keyPreviewLayout="@layout/preview" />
    <include
        layout="@layout/login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/keyboard1" />
</RelativeLayout>
and my onCreateInputView method will look like this
@Override
    public View onCreateInputView() {
        final RelativeLayout layout = (RelativeLayout) getLayoutInflater().inflate(R.layout.keyboard_layout, null);
        kv = (KeyboardView) layout.findViewById(R.id.keyboard1);
        keyboard = new Keyboard(this, R.xml.qwerty);
        kv.setKeyboard(keyboard);
        kv.setOnKeyboardActionListener(this);
        return layout;
    }
 
    
    
        Ujjwal Bansal
        
- 289
- 1
- 4
- 24

