Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android replace keyboard with Emoji Fragment

I'm making a little chat in my app and I have an Emoticon Fragment (just like the one from whatsapp or telegram). How can I switch between the fragment and the keyboard without any weird animation?

I already have the fragment wih the emojis and the custom EditText. I just want to switch beween that fragment and keyboard. I really want it to work like whatsapp or Telegram.

For the emoticon Fragment I made a library. I add a fragment (Grid view with SpannableTextViews for each emoji) in the same layout as the EditText.

Any help will be really appreciated.

like image 907
stanete Avatar asked Jan 11 '23 15:01

stanete


1 Answers

You don't need to replace the keyboard, you can put your fragment over activity using PopupWindow as Telegram does. Just look at the source: method showEmojiPopup creates EmojiView and put it inside PopupWindow then calculates appropriate size and shows it.

emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(contentView.getWidth(), View.MeasureSpec.EXACTLY));

emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
like image 110
eleven Avatar answered Jan 18 '23 01:01

eleven