1

我正在为我的软键盘使用以下代码(这是其中的一部分)。

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

由于某种原因stylekeyIcon不起作用。无论如何,我不能只将键盘上的一个按钮设置为不同的布局。我究竟做错了什么?我只尝试了 style 和 keyIcon,但到目前为止没有任何组合有效。

<style name="deleteKeyboard">
    <item name="android:keyTextColor">#EEEEEE</item>
    <item name="android:keyBackground">@drawable/button_delete</item>
    <item name="android:keyTextSize">15sp</item>
</style>
4

1 回答 1

2

事实证明,keyIcon 不能与 android:keyLabel 结合使用。这是我可以解决的唯一方法。

<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 和 clear_numeric 只是带有 CLR 和 DEL 的透明 PNG(见下文)。要改变那些我不得不在android:background="@drawable/numeric_background"里面使用的背景<android.inputmethodservice.KeyboardView />。这是一个PNG,在这些按钮下方有背景和彩色补丁(您还需要使按钮背景半透明!)。图像的大小无关紧要,因为它会拉伸。

  • 数字背景.png

数字背景.PNG

  • clear_numeric.png 和 delete_numeric.png

clear_numeric 删除数字

于 2013-06-14T21:49:07.537 回答