我正在尝试为 Android 创建一个自定义键盘。我使用软键盘示例应用程序作为起点。我的问题是我无法在键盘中居中一行,而我在网上找到的其他示例显然可以工作。
我的 XML 文件如下所示:
<?xml version="1.0" encoding="utf-8"?><Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="@dimen/horizontal_gap"
android:keyHeight="@dimen/key_height"
android:keyWidth="10%p"
android:verticalGap="@dimen/vertical_gap" >
<Row>
<Key
android:codes="49"
android:keyEdgeFlags="left"
android:keyLabel="1" />
<Key
android:codes="50"
android:keyLabel="2" />
<Key
android:codes="51"
android:keyLabel="3" />
<Key
android:codes="52"
android:keyLabel="4" />
<Key
android:codes="53"
android:keyLabel="5" />
<Key
android:codes="54"
android:keyLabel="6" />
<Key
android:codes="55"
android:keyLabel="7" />
<Key
android:codes="56"
android:keyLabel="8" />
<Key
android:codes="57"
android:keyLabel="9" />
<Key
android:codes="48"
android:keyEdgeFlags="right"
android:keyLabel="0" />
</Row>
<Row>
<Key
android:codes="1"
android:keyEdgeFlags="left"
android:keyLabel="q" />
<Key
android:codes="2"
android:keyLabel="w" />
<Key
android:codes="3"
android:keyLabel="e" />
<Key
android:codes="4"
android:keyLabel="r" />
<Key
android:codes="5"
android:keyLabel="t" />
<Key
android:codes="6"
android:keyLabel="y" />
<Key
android:codes="-5"
android:isRepeatable="true"
android:keyEdgeFlags="right"
android:keyIcon="@drawable/sym_keyboard_delete" />
</Row>
<Row>
<Key
android:codes="99"
android:keyEdgeFlags="left"
android:keyLabel="c" />
<Key
android:codes="32"
android:isRepeatable="true"
android:keyIcon="@drawable/sym_keyboard_space"
android:keyWidth="30%p" />
<Key
android:codes="63"
android:keyLabel="\?"
android:keyWidth="@dimen/small_buttons" />
<Key
android:codes="33"
android:keyLabel="!"
android:keyWidth="@dimen/small_buttons" />
<Key
android:codes="46"
android:keyLabel="."
android:keyWidth="@dimen/small_buttons" />
<Key
android:codes="44"
android:keyEdgeFlags="right"
android:keyLabel=","
android:keyWidth="@dimen/small_buttons" />
</Row></Keyboard>
为了使第二行和第三行居中,缺少什么?
提前致谢。