在运行时将行和键添加到android中的自定义键盘
我正在开发一个应用程序,在这个应用程序中,我需要用java代码按语法创建自定义键盘的行和键,而不是使用XML。 这可能吗?如果是,我们如何做到这一点 目前,我正在使用XML并以以下方式创建行:-在运行时将行和键添加到android中的自定义键盘,android,keyboard,custom-keyboard,Android,Keyboard,Custom Keyboard,我正在开发一个应用程序,在这个应用程序中,我需要用java代码按语法创建自定义键盘的行和键,而不是使用XML。 这可能吗?如果是,我们如何做到这一点 目前,我正在使用XML并以以下方式创建行:- <Keyboard android:keyWidth="10.0%p" android:keyHeight="@dimen/key_height" android:horizontalGap="0.0px"android:verticalGap="0.0px" xmlns:android="ht
<Keyboard android:keyWidth="10.0%p"
android:keyHeight="@dimen/key_height" android:horizontalGap="0.0px"android:verticalGap="0.0px"
xmlns:android="http://schemas.android.com/apk/res/android">
<Row android:rowEdgeFlags="top" >
<Key android:codes="-21" android:keyIcon="@drawable/arbiclinenew" />
<Key android:codes="-51" android:keyIcon="@drawable/recentlinenew" />
</Row>
基本上,我需要在我的键盘上显示“最近的”
视图,该视图显示用户最近选择的所有表情符号,与whatsapp中相同。
请帮忙 最后,我可以创建自己的自定义键盘。我们可以创建自定义键盘布局来显示最近的按钮。例如:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textDirection="rtl"
android:keyPreviewLayout ="@layout/preview"></android.inputmethodservice.KeyboardView>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</FrameLayout>
现在,假设在任何按键上单击,您需要显示表情符号或任何其他视图,然后我们可以设置键盘可见性:不可见,并可以显示您自己的布局