问题
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