Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 自定义软键盘布局尺寸_Android_Android Layout_Android Softkeyboard - Fatal编程技术网

Android 自定义软键盘布局尺寸

Android 自定义软键盘布局尺寸,android,android-layout,android-softkeyboard,Android,Android Layout,Android Softkeyboard,我做了一个定制的软键盘 XML文件: <?xml version="1.0" encoding="UTF-8"?> <android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/keyboard" andr

我做了一个定制的软键盘

XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyboard"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="#1B0A33"
    android:keyBackground="@drawable/pexeso_keyboard_key"
/>
现在看来是这样的:

我希望它看起来如此:


如何调整布局,最好的解决方案是什么?欢迎所有想法

这比我想象的要容易。我只编辑布局-将键盘视图添加到相对布局。然后将LayoutInflater添加到onCreateInputView()

Java

@Override
    public View onCreateInputView() {

        LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = li.inflate(R.layout.pexeso_keyboard_layout, null);
        kvw = (KeyboardView)v.findViewById(R.id.keyboard);
        keyboard = new Keyboard(this, R.xml.pexeso_keyboard_map);
        kvw.setKeyboard(keyboard);
        kvw.setOnKeyboardActionListener(this);
        kvw.setPreviewEnabled(false);
        keyboardMinWidth = kvw.getKeyboard().getMinWidth();
        displayWidth = getApplication().getResources().getDisplayMetrics().widthPixels;
        kvw.invalidateAllKeys();
        return v;
    }
布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/pxs_keyboard_background"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="center_vertical|bottom">

    <android.inputmethodservice.KeyboardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/keyboard"
        android:layout_margin="35dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/pxs_keyboard_background"
        android:keyBackground="@drawable/pexeso_keyboard_key"
        android:layout_centerHorizontal="true">
    </android.inputmethodservice.KeyboardView>

</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/pxs_keyboard_background"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="center_vertical|bottom">

    <android.inputmethodservice.KeyboardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/keyboard"
        android:layout_margin="35dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/pxs_keyboard_background"
        android:keyBackground="@drawable/pexeso_keyboard_key"
        android:layout_centerHorizontal="true">
    </android.inputmethodservice.KeyboardView>

</RelativeLayout>