android怎么打开表情软键盘,如何在表情符号键盘和软键盘之间进行转换
我正在研究android即时聊天应用程序。我已经成功实现了它的基本功能。现在我已经使用库编译“com.rockerhieu.emojicon:library:1.3.3”添加了一组表情符号。我在我的xml文件中使用FrameLayout来显示图释。如何在表情符号键盘和软键盘之间进行转换1 activity_chat.xmlandroid:layout_width="match_parent"and
我正在研究android即时聊天应用程序。我已经成功实现了它的基本功能。现在我已经使用库编译“com.rockerhieu.emojicon:library:1.3.3”添加了一组表情符号。我在我的xml文件中使用FrameLayout来显示图释。如何在表情符号键盘和软键盘之间进行转换
1 activity_chat.xml
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FCAB26"
android:orientation="vertical"
android:weightSum="1">
android:id="@+id/list_view_messages"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".60"
android:background="@null"
android:divider="@null"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight=".10"
android:orientation="horizontal"
android:weightSum="1">
android:id="@+id/imgSmile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".10"
android:src="@drawable/ic_msg_panel_smiles"
android:layout_gravity="center_vertical"
android:layout_marginRight="-10sp"/>
android:id="@+id/edtMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:hint="Enter Message"
android:layout_weight=".60">
android:id="@+id/btnSendMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight=".30"
android:gravity="center"
android:onClick="onClick"
android:text="Send Message" />
android:id="@+id/emojicons"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".30"
android:visibility="gone" />
在这里,就连指定的可见度走后,FrameLayout里占据一定的空间。
其显示通过上述库的表情符号的面板的代码在下面给出:
// This method will set a panel of emoticons in the fragment
private void setEmojiconFragment(boolean useSystemDefault) {
// Replacing the existing fragment having id emojicons with the fragment of emoticons library containing emoticons
getSupportFragmentManager().beginTransaction().replace(R.id.emojicons, EmojiconsFragment.newInstance(useSystemDefault)).commit();
}
3.Screenshot

为u可以在屏幕截图看到,我有一个imageview,一个edittext和发送消息按钮。点击imageview,显示表情符号面板,并点击edittext enoji键盘被隐藏,软键盘显示编辑。下面的代码处理这个。
显示表情弹出:
public void showEmojiPopUp(boolean showEmoji) {
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.emojicons);
frameLayout.setVisibility(View.VISIBLE);
}
隐藏softkeyboard:
public void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
我的问题是,我想的表情符号键盘和软键盘占据.AT时间相等的空间只有一个应该是可见的。我想在表情符号键盘和软键盘之间进行转换。如你在代码中看到的那样,我在FrameLayout中添加了表情符号键盘。我无法使软键盘和表情符号键盘的大小相等。请帮我解决这个问题。
编辑代码: 我在我的代码做了一些修改:
shoEmojiPopUp()方法:在这里,我们正在调整的FrameLayout含有表情符号的面板高度,使软键盘的高度和表情符号键盘是一样的。
public void showEmojiPopUp(boolean showEmoji) {
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
deviceHeight = size.y;
Log.e("Device Height", String.valueOf(deviceHeight));
frameLayout = (FrameLayout) findViewById(R.id.emojicons);
frameLayout.getLayoutParams().height = (int) (deviceHeight/2.5); // Setting the height of FrameLayout
frameLayout.requestLayout();
frameLayout.setVisibility(View.VISIBLE);
hideKeyboard();
}
2. hideKryboard()方法
// Hiding the keyboard
public void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
它现在为我工作。
+0
喜...你找到任何解决办法?我有同样的问题 –
+0
thanx很多.... –
+0
请告诉我它是否适合你。 –
更多推荐



所有评论(0)