Skip to content

candRabbit/EmojiView-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emoji View

Features

  • There are 845 emoji characters.
  • EmojiView: used for selecting and entering emoji characters in specified one category.
  • EmojiViewEx: used for selecting and entering emoji characters in all category.
  • EmojiEditView & EmojiTextView: used for editing and showing texts with emoji respectively. (Native EditView and TextView could also be used for showing emoji characters.)
  • Emoji characters are encoded in corresponding Unicode.
  • A lighter library contains only people category.

EmojiView

EmojiView

  • The process of resources loading is lazy.
  • The number of rows and columns could be customized.
  • Navigator dots on the bottom and the color could be customized.

EmojiViewEx

EmojiViewEx

  • Customize border color and the height of category tab.

Instruction

Import library

Import Library

Layout file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:emoji="http://schemas.android.com/apk/res/zhaohg.emojiviewdemo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:layout_gravity="fill">

    <zhaohg.emojiview.EmojiEditText
        android:id="@+id/emojiEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >
        <requestFocus />
    </zhaohg.emojiview.EmojiEditText>
    
    <zhaohg.emojiview.EmojiViewEx
        android:id="@+id/emojiView"
        android:layout_width="match_parent"
        android:layout_height="190dp"
        android:background="#EEEEEE"
        emoji:indicatorDotsColor="#222222"
        emoji:categoryHeight="40dp"/>

</LinearLayout>

Set EditText

EditText editText = (EditText) this.findViewById(R.id.emojiEditText);
EmojiView emojiView = (EmojiViewEx) this.findViewById(R.id.emojiView);
emojiView.setEditText(editText);

Use Native EditText and TextView

For EditText overload the onTextChanged method:

@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
    this.setupEmoji(start, lengthAfter);
}

private void setupEmoji(int start, int length) {
	EmojiSetup.setupEmoji(this.getContext(), this.getText(), (int)this.getTextSize(), start, length);
}

For TextView overload the setText method:

@Override
public void setText(CharSequence text, BufferType type) {
    SpannableStringBuilder builder = new SpannableStringBuilder(text);
    EmojiSetup.setupEmoji(this.getContext(), builder, (int) this.getTextSize());
	super.setText(builder, type);
}

Acknowledgements

About

😼 EmojiView for Android.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 96.7%
  • Python 3.0%
  • MATLAB 0.3%