Android custom keyboard?

江枫思渺然 提交于 2019-12-24 08:39:08

问题


Hello I am working on Custom KEYBOARD for my app.

i.e

<Keyboard
         android:keyWidth="%10p"
         android:keyHeight="50px"
         android:horizontalGap="2px"
         android:verticalGap="2px" >
     <Row android:keyWidth="32px" >
         <Key android:keyLabel="A" />
         ...
     </Row>
     ...
 </Keyboard>

I want to know is there any method or android tag available for set invisible or visible the keyboard board key.

like android:visibility="gone" or setVisibility(View.GONE) for Keyboard layout.

Cause in my app there are many variation in Keyboard.

any information regarding this.


回答1:


It is possible to hide a key by changing the width of a key.

The following is an example of hiding language-switch key:

void setLanguageSwitchKeyVisibility(boolean visible) {
    if (visible) {
        // The language switch key should be visible. Restore the size of the mode change key
        // and language switch key using the saved layout.
        mModeChangeKey.width = mSavedModeChangeKey.width;
        mModeChangeKey.x = mSavedModeChangeKey.x;
        mLanguageSwitchKey.width = mSavedLanguageSwitchKey.width;
        mLanguageSwitchKey.icon = mSavedLanguageSwitchKey.icon;
        mLanguageSwitchKey.iconPreview = mSavedLanguageSwitchKey.iconPreview;
    } else {
        // The language switch key should be hidden. Change the width of the mode change key
        // to fill the space of the language key so that the user will not see any strange gap.
        mModeChangeKey.width = mSavedModeChangeKey.width + mSavedLanguageSwitchKey.width;
        mLanguageSwitchKey.width = 0;
        mLanguageSwitchKey.icon = null;
        mLanguageSwitchKey.iconPreview = null;
    }
}

Edit LatinKeyboard to hide a key.



来源:https://stackoverflow.com/questions/17232871/android-custom-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!