Android Inputmethodeditor Layout File. Non-key/row Elements In The Xml?
I'm trying to implement a keyboard with a TextView that updates with each keypress, but it won't show up on the screen. It should appear above the top row of letters. When I run th
Solution 1:
You will have to change your keyboard layout to contain your TextView
and KeyboardView
.
1) change IME layout as below:
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"
><TextViewandroid:id="@+id/tvKeyboard"android:layout_width="match_parent"android:layout_height="48dp"android:gravity="center"android:padding="10dp"android:scaleType="fitEnd"android:src="@drawable/keyboard_icon" /></RelativeLayout><android.inputmethodservice.KeyboardViewxmlns: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"
/></LinearLayout>
2) In your IME class make a few changes:
@Overridepublic View onCreateInputView() {
finalViewroot= getLayoutInflater().inflate(R.layout.idee_keyboard_layout, null);
TextViewtvKeyboard= (TextView) root.findViewById(R.id.tvRevertKeyboard);
tvKeyboard.setText("set your text here");
kv = (KeyboardView) root.findViewById(R.id.keyboard);
keyboard = newKeyboard(this, R.xml.qwerty);
kv.setKeyboard(keyboard);
kv.setOnKeyboardActionListener(this);
return root;
}
Done.
Solution 2:
Nesting the TextView in the ReleativeLayout and that RelativeLayout with the KeyboardView in a LinearLayout resulted in the TextView being displayed. A couple more bugs came up, but after rebuilding the project, they subsided. Thanks for the help!
Post a Comment for "Android Inputmethodeditor Layout File. Non-key/row Elements In The Xml?"