2017-02-22 44 views
0

example如何TextView中添加到自定义键盘顶部

@Override public View onCreateInputView() { 
    kv = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null); 
    keyboard = new Keyboard(this, R.xml.qwerty); kv.setKeyboard(keyboard); 
    UserDictionary.Words.addWord(this, "MadeUpWord", 10, "Mad", Locale.getDefault()); 
    kv.setOnKeyboardActionListener(this); 
    return kv; 
} 

回答

0

你可以按照下面的链接进行自定义键盘:

Create a Custom Keyboard on Android

创建一个文件名为RES /布局/键盘.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:keyPreviewLayout ="@layout/preview" 
/> 

keyPreviewLayout是每当按下键盘上的按键时显示的短暂弹出窗口的布局。它包含一个单独的TextView。创建一个文件名为RES /布局/ preview.xml并添加以下代码行:

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:background="#ffff00" 
    android:textStyle="bold" 
    android:textSize="30sp" 
    >  
</TextView> 
+0

感谢您的答复,但我已经做到了这一点,现在我需要在键盘的上方,显示文本建议添加的TextView ... –

相关问题