我用下面的code(这是它的一部分),为我softKeyboard。
<行机器人:rowEdgeFlags =底> <关键 机器人:codeS =83 机器人:keyLabel =CLR/> <关键 机器人:codeS =39 机器人:keyLabel =0/> <关键 机器人:codeS =42 风格=@风格/ deleteKeyboard 机器人:keyIcon =@绘制/ button_delete 机器人:isRepeatable =真 机器人:keyLabel =DEL/>< /行>
由于某些原因的样式或 keyIcon 将无法工作。没有什么事,我不能设置键盘不同的布局上只有一个按钮。我究竟做错了什么?我尝试了风格和keyIcon,但没有组合至今工作。
<样式名称=deleteKeyboard> <项目名称=机器人:keyTextColor>#EEEEEE< /项目> <项目名称=机器人:keyBackground> @绘制/ button_delete< /项目> <项目名称=机器人:keyTextSize> 15sp< /项目>< /风格>
解决方案
事实证明,keyIcon无法与Android相结合:keyLabel。这是我能解决的唯一途径。
<行机器人:rowEdgeFlags =底> <关键 机器人:keyIcon =@绘制/ clear_numeric 机器人:codeS =83/> <关键 机器人:codeS =39 机器人:keyLabel =0/> <关键 机器人:codeS =42 机器人:keyIcon =@绘制/ delete_numeric 机器人:isRepeatable =真/> < /行>
delete_numeric和clear_numeric只是透明的PNG(见下文)与CLR和DEL就可以了。要改变这些,我不得不使用的android背景:背景=@绘制/ numeric_background
在< android.inputmethodservice.KeyboardView />
。这与下面这些按钮的背景和色斑一个PNG(你还需要按钮背景半透明!)。图像的大小并不重要,因为它会伸长
clear_numeric.png和delete_numeric.png
I'm using the following code (this is a part of it) for my softKeyboard.
<Row android:rowEdgeFlags="bottom" >
<Key
android:codes="83"
android:keyLabel="CLR" />
<Key
android:codes="39"
android:keyLabel="0" />
<Key
android:codes="42"
style="@style/deleteKeyboard"
android:keyIcon="@drawable/button_delete"
android:isRepeatable="true"
android:keyLabel="DEL" />
</Row>
For some reason style or keyIcon won't work. Not matter what, I can't set only one button on keyboard to different layout. What am I doing wrong? I tried just with style and keyIcon, but no combination worked so far.
<style name="deleteKeyboard">
<item name="android:keyTextColor">#EEEEEE</item>
<item name="android:keyBackground">@drawable/button_delete</item>
<item name="android:keyTextSize">15sp</item>
</style>
解决方案
As it turns out, keyIcon cannot be combined with android:keyLabel. This is the only way I could solve that.
<Row android:rowEdgeFlags="bottom" >
<Key
android:keyIcon="@drawable/clear_numeric"
android:codes="83"/>
<Key
android:codes="39"
android:keyLabel="0" />
<Key
android:codes="42"
android:keyIcon="@drawable/delete_numeric"
android:isRepeatable="true"/>
</Row>
delete_numeric and clear_numeric are just transparent PNGs (see below) with CLR and DEL on it. To change background of those I had to use android:background="@drawable/numeric_background"
inside <android.inputmethodservice.KeyboardView />
. This is a PNG with background and colored patches below those buttons (you also need to make button background half transparent!). Size of the image does not matter, as it will stretch.
相关推荐
最新文章