How can I implement special soft keyboard

后端 未结 1 1929
误落风尘
误落风尘 2020-12-13 10:32

I want to make special soft keyboard to use it in my android app like the following

\"enter

相关标签:
1条回答
  • 2020-12-13 11:33

    Create XML like this for keyboard :

    <?xml version="1.0" encoding="utf-8"?>
    <com.YourKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/keyboard"
        style="@style/keyboard_1_style"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
    </com.YourKeyboardView>
    

    And style is as below:

     <style name="keyboard_1_style">
            <item name="android:keyBackground">@drawable/k1_selector</item>
            <item name="android:keyTextColor">#24B2E7</item>
            <item name="android:background">@android:color/white</item>
            <item name="android:keyPreviewLayout">@layout/k1_preview</item>
     </style>
    

    In which

    <item name="android:keyBackground">@drawable/k1_selector</item>
    

    is used to set background for key.

    <item name="android:keyTextColor">#24B2E7</item> 
    

    is used for text color of key.

    <item name="android:background">@android:color/white</item> 
    

    is used to set background of entire keyboard and

    <item name="android:keyPreviewLayout">@layout/k1_preview</item>
    

    is uesd to set preview of key.

    Preview layout xml :

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40sp"
        android:textColor="@android:color/white"
        android:gravity="center"
        android:background="@drawable/neon_candidate_middle_pressed"/>
    

    For spaces between keys use this.

    And for android:background="@drawable/neon_candidate_middle_pressed" it is background image which you want to show in preview of key.

    0 讨论(0)
提交回复
热议问题