Search code examples
javaandroidviewkeyboardandroid-custom-view

Create custom keyboard in android using different layout and keys not being rectangle, shape picked from the drawable image


I have tried to use the custom keyboard in android. I tried the following links Custom keyboard - Android

I have also tried to create a custom keyboard using Android Custom keyboard link.

All these have a custom keyboard, but it uses the default key pattern of android.

I would like to create a keypad without such look and feel.

I want to create a keyboard with a key having occupied two rows in a column whereas some can occupy a space of 4 keys(2x2).

Example : https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRtHoD_LfzD4AepsAffO2WQbMYzWlQdymMWAXqz47s8EwvryYNW

Look at the enter key in this keyboard.

Also, I want to use drawable images that can be used as the key, which can have wierd design. I would want to create the image shape depending on the png image.


Solution

  • I used the ImageButton and specified a source file for the drawable image.

    This helped me with the image on the button, but the button still occupied a rectangle section. To remove the alpha region, I seeked help of the android:background property of ImageButton in android layout file.

        android:background="@android:color/transparent"
        android:src="@drawable/your_image"
    

    Now, if you want to disallow button taps on those regions, you can refer the following link. Hexagon button with hexagon touch area