gpt4 book ai didi

android - 表情符号软键盘就像 android 中的 Whatsapp

转载 作者:太空狗 更新时间:2023-10-29 14:55:04 27 4
gpt4 key购买 nike

I am interested in creating Whatsapp like Emoji keyboard in Android. I am successful in creating Emoji keyboard.

现在我想向我的自定义键盘(InputMethod) 添加两个滚动条。

首先键盘上方的水平滚动条(就像在kitkat中一样),用于选择类别 Like(Nature,People,Place ,符号) .

其次。我想添加一个表情符号的垂直 GridView。因此,无需一次又一次地单击 categories 以获得完整列表。

到目前为止我尝试了什么。

我创建了我的 input.xml 就像

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<com.zeuxislo.emojikeyboard.EmojiKeyboardView
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_gravity="bottom"
android:keyBackground="@drawable/samplekeybackground" >
</com.zeuxislo.emojikeyboard.EmojiKeyboardView>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Wao what a keyBoard"
android:textSize="24sp" />
</LinearLayout>

</ScrollView>

并且在 SoftKeyboard.java

public View onCreateInputView() 
{
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

testInput = inflater.inflate(R.layout.test_input, null);

mInputView = (KeyboardView) testInput.findViewById(R.id.keyboard);

this.mInputView = (KeyboardView) this.getLayoutInflater().inflate(R.layout.input, null);
//this.mInputView = (KeyboardView) this.getLayoutInflater().inflate(R.layout.input, null);
this.mInputView.setOnKeyboardActionListener(this);
this.mInputView.setKeyboard(this.mQwertyKeyboard);
return this.mInputView;
}

Also tried putting TextView above and below the layout. But it doesn't display. How can I do it?

而且我还尝试添加一个 Horizo​​ntalScrollView 之类的

<Keyboard  android:keyWidth="10.000002%p" android:keyHeight="@dimen/key_height" android:horizontalGap="0.0px" android:verticalGap="0.0px"
xmlns:android="http://schemas.android.com/apk/res/android">

<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<Row android:rowEdgeFlags="bottom">
<Key android:keyWidth="14.999998%p" android:codes="-1009" android:keyEdgeFlags="left" android:keyIcon="@drawable/sym_keyboard_done" />
<Key android:keyWidth="10.000002%p" android:codes="-1010" android:keyLabel="ABC" />
<Key android:keyWidth="10.000002%p" android:codes="-1011" android:keyLabel="123" />
<Key android:keyWidth="10.000002%p" android:codes="-1012" android:keyIcon="@drawable/e415" />
<Key android:keyWidth="10.000002%p" android:codes="-1013" android:keyIcon="@drawable/e04a" />
<Key android:keyWidth="10.000002%p" android:codes="-1014" android:keyIcon="@drawable/e033" />
<Key android:keyWidth="10.000002%p" android:codes="-1015" android:keyIcon="@drawable/e01d" />
<Key android:keyWidth="10.000002%p" android:codes="-1016" android:keyIcon="@drawable/e214" />
<Key android:keyWidth="14.999998%p" android:codes="-1017" android:keyEdgeFlags="right" android:keyIcon="@drawable/sym_keyboard_return" />

<Key android:keyWidth="14.999998%p" android:codes="-1021" android:keyEdgeFlags="left" android:keyIcon="@drawable/sym_keyboard_done" />
<Key android:keyWidth="10.000002%p" android:codes="-1022" android:keyLabel="ABC" />
<Key android:keyWidth="10.000002%p" android:codes="-1023" android:keyLabel="123" />
<Key android:keyWidth="10.000002%p" android:codes="-1024" android:keyIcon="@drawable/e415" />
<Key android:keyWidth="10.000002%p" android:codes="-1025" android:keyIcon="@drawable/e04a" />
</Row>
</HorizontalScrollView>

</Keyboard >

最佳答案

基本上,您为表情符号键盘所做的一切就是创建键盘大小的 View ,然后使用与表情符号对应的图像文件填充该 View 。每个图像都像一个按钮,并将适当的表情符号传送到 inputConnection。

我发现表情符号键盘的最佳实现是 sliding emoji-Keyboard。 .我能够 fork 该项目并进行清理并对其进行了相当多的增强。你可以看看我的emoji-Keyboard尝试理解我采用的方法。

关于android - 表情符号软键盘就像 android 中的 Whatsapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32270209/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com