0

i am trying to build a keyboard. everything was working great until i tried to make custom style for keys. Now the keyboard wont pop up even when i click the chat box. this is my styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="Theme.Keyboard.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorOnSecondary">@color/white</item>
        <item name="android:windowBackground">@color/white</item>
    </style>

    <style name="CustomKeyboardButtonStyle" parent="Widget.AppCompat.Button">
    <item name="android:background">@drawable/key_background</item>
    </style>
    <style name="CustomKeyStyle" parent="CustomKeyboardButtonStyle">
        <!-- add any additional key customizations here -->
    </style>

</resources>

this is my key_layout.xml-

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="10%p"
    android:horizontalGap="4dp"
    android:verticalGap="4dp"
    android:keyHeight="52dp"
    android:keyTextColor="#000000"
    android:keyBackground="@drawable/key_background"
    style="@style/CustomKeyboardButtonStyle"
    >
    <Row android:keyHeight="52dp"  android:rowEdgeFlags="top">
        <Key  android:codes="-100" android:keyWidth="100%p"  />
    </Row>

    <Row style="@style/CustomKeyboardButtonStyle">
        <Key android:codes="113" android:keyLabel="q" android:keyEdgeFlags="left"/>
        <Key android:codes="119" android:keyLabel="w"/>
        <Key android:codes="101" android:keyLabel="e"/>
        <Key android:codes="114" android:keyLabel="r"/>
        <Key android:codes="116" android:keyLabel="t"/>
        <Key android:codes="121" android:keyLabel="y"/>
        <Key android:codes="117" android:keyLabel="u"/>
        <Key android:codes="105" android:keyLabel="i"/>
        <Key android:codes="111" android:keyLabel="o"/>
        <Key android:codes="112" android:keyLabel="p" android:keyEdgeFlags="right"/>
    </Row>
    <Row style="@style/CustomKeyboardButtonStyle">
        <Key android:codes="97" android:keyLabel="a" />
        <Key android:codes="115" android:keyLabel="s"/>
        <Key android:codes="100" android:keyLabel="d"/>
        <Key android:codes="102" android:keyLabel="f"/>
        <Key android:codes="103" android:keyLabel="g"/>
        <Key android:codes="104" android:keyLabel="h"/>
        <Key android:codes="106" android:keyLabel="j"/>
        <Key android:codes="107" android:keyLabel="k"/>
        <Key android:codes="108" android:keyLabel="l"/>
    </Row>
    <Row style="@style/CustomKeyboardButtonStyle">
        <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift" android:keyEdgeFlags="left"/>
        <Key android:codes="122" android:keyLabel="z"/>
        <Key android:codes="120" android:keyLabel="x"/>
        <Key android:codes="99" android:keyLabel="c"/>
        <Key android:codes="118" android:keyLabel="v"/>
        <Key android:codes="98" android:keyLabel="b"/>
        <Key android:codes="110" android:keyLabel="n"/>
        <Key android:codes="109" android:keyLabel="m"/>
        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" android:isRepeatable="true" android:keyEdgeFlags="right"/>
    </Row>
    <Row android:rowEdgeFlags="bottom" style="@style/CustomKeyboardButtonStyle">
        <Key android:codes="44" android:keyLabel="," android:keyWidth="25%p"  android:keyEdgeFlags="left"/>
        <Key android:codes="32" android:keyLabel="space" android:keyIcon="@drawable/sym_keyboard_space" android:keyWidth="75%p" android:isRepeatable="true"/>
        <Key android:codes="-4" android:keyIcon="@drawable/sym_keyboard_return" android:keyLabel="return" android:keyWidth="25%p" android:keyEdgeFlags="right"/>
    </Row>

</Keyboard>

this is my keyboard_view.xml

<?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/keyboard_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:theme="@style/Theme.AppCompat"
        style="@style/CustomKeyboardButtonStyle" />

</RelativeLayout>

and this is my key_background.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Key background in its normal state -->
    <item android:drawable="@drawable/key_background_normal"/>

    <!-- Key background in its pressed state -->
    <item android:drawable="@drawable/key_background_pressed" android:state_pressed="true"/>

    <!-- Key background in its focused state (when the key gains focus) -->
    <item android:drawable="@drawable/key_background_focused" android:state_focused="true"/>

</selector>

if you want the code of any other file.. please tell me. thanks for reading so much.

I was just trying to add some color to the keyboard.. no matter what i did the default color (the blackish marble like color) sticked to the keyboard. so i tried to style the keys first but after i did a little research and tried few things, i ended up in this situation. please help me, i am new in this field.

edit - i tried using chatgpt to fix it but it didnt help either

0 Answers0