我一直在开发自定义键盘,但是我遇到了一个问题,无法解决。我试图将每行的所有按键都居中对齐。我的意思是,即使一行有9、10或11个按键,所有按键也都居中对齐。这是我的键盘目前的样子:http://postimg.org/image/6jy1uyd6x/。我做错了什么?这是我的xml文件:
这是我的keyboard.xml文件:
我不想使用%p,因为这不是解决此问题的最佳方式。 提前感谢您!
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="1%p"
android:verticalGap="0.4%p"
>
<Row android:keyWidth="9%p" android:keyHeight="75dip" android:rowEdgeFlags="top">
<Key android:codes="49" android:keyLabel=";" android:keyEdgeFlags="left"/>
<Key android:codes="50" android:keyLabel="ς"/>
<Key android:codes="51" android:keyLabel="ε"/>
<Key android:codes="52" android:keyLabel="ρ"/>
<Key android:codes="53" android:keyLabel="τ"/>
<Key android:codes="54" android:keyLabel="υ"/>
<Key android:codes="55" android:keyLabel="θ"/>
<Key android:codes="56" android:keyLabel="ι"/>
<Key android:codes="57" android:keyLabel="ο"/>
<Key android:codes="48" android:keyLabel="π" android:keyEdgeFlags="right"/>
</Row>
这是我的keyboard.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/keyboard"
android:imeOptions="flagNoFullscreen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center|fill_horizontal"
android:layout_alignParentBottom="true"
android:keyPreviewLayout ="@layout/preview"
android:keyBackground="@drawable/key_background"
android:keyTextSize="35sp"
android:keyTextColor="@color/key_text_color"
android:keyPreviewHeight="50sp"
android:shadowRadius="1"
android:shadowColor="#fff"
android:padding="0px" android:layout_margin="0px"
tools:ignore="ResAuto" />
我不想使用%p,因为这不是解决此问题的最佳方式。 提前感谢您!