小编Geo*_*rge的帖子

Android 软键盘按键重心

我一直在研究自定义键盘,但遇到了一个我无法解决的问题。我正在尝试调整中心每一行的所有键。我的意思是,即使一行有 9 个或 10 个或 11 个键,所有键都在中心对齐。这是我的键盘现在的样子:

http://postimg.org/image/6jy1uyd6x/

我究竟做错了什么?这也是我的 xml 文件:

    <?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>
Run Code Online (Sandbox Code Playgroud)

这是我的 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" …
Run Code Online (Sandbox Code Playgroud)

java keyboard android

5
推荐指数
1
解决办法
1860
查看次数

标签 统计

android ×1

java ×1

keyboard ×1