禁用自定义键盘Android中的一个关键的 [英] Disable one key on custom keyboard in Android
问题描述
我有自定义键盘我的应用程序的Android系统。它的布局在这样的XML描述
I have custom keyboard in my app for Android. It's layout described in xml like this
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"">
<Row>
<Key android:keyLabel="F1" android:keyOutputText="F1"/>
<Key android:keyLabel="F2" android:keyOutputText="F2"/>
<Key android:keyLabel="F3" android:keyOutputText="F3"/>
...
所以,我insteresting我怎么可以禁用,例如F1键〜使其灰色和碰不得。
有一些类似的问题在这里,但所有有关默认软KB。
So, i'm insteresting how i can disable, for example 'f1' key ~ make it grey and untouchable. There are some similar questions here, but all about default soft-KB.
我知道我可以通过这样的循环键
I know I can iterate through keys like this
for (Keyboard.Key key : myKeyboard.getKeys())
但它看起来像 Keyboard.Key <对象/ A>类是没有用在关键的外观进行任何更改。
but it's look like objects of Keyboard.Key class are useless for any changes in key's look.
UPD :我没有找到解决办法。我实现手动键盘 - 大相对布局,常用的按钮和自定义按钮,一切都很好。顺便说一句 - 自定义键盘,至少更漂亮。只需复制从机器人4+的资源 - 你会在每个平台上得到很好的现代的透明按钮,透明的布局
UPD: I did not found solution. I implemented keyboard manually - big relative layout, common buttons and custom buttons and everything fine. By the way - custom keyboard at least more beautiful. Just copy resources from droid 4+ - and you'll get nice modern transparent buttons and transparent layout on every platform.
推荐答案
我目前使用的android:horizontalGap的
放置一个黑色的间隙(带钥匙的宽度)在残疾人关键应放在(以这种方式,我可以隐藏在每个屏幕不允许的钥匙,因为我的键盘上总是相同的分布)的地方。这是一个贫穷的解决办法,但。
I am currently using android:horizontalGap
to place a black gap (with the width of a key) in the place where the disabled key should be placed (in this way, I can hide keys not allowed in each screen, because my keyboard has always the same distribution). It's a poor workaround, though.
主要的问题是最右边的按键,因为的android:horizontalGap的
只能一键的左侧设置。但是,使用的android:keyWidth =在最右边的假0键
属性,然后设置有适当的的android:horizontalGap的
,是卓有成效的。一个更加贫困的解决方法...
The main problem is for the rightmost keys, since android:horizontalGap
can only be set for the left side of a key. But using an android:keyWidth="0"
attribute in a rightmost fake key and then setting there the proper android:horizontalGap
, does the trick. An even poorer workaround...
任何更好的解决方案?
这篇关于禁用自定义键盘Android中的一个关键的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!