EmojiSlider is a widget view in android, it can allow users to create some beautiful and custom emoji sliders in android.
How to create emoji sliders in android?
Step 1: add a dependency to your build.gradle
dependencies { implementation 'com.bernaferrari.emojislider:emojislider:0.3.2' }
Step 2: add the EmojiSlider in your layout
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content"> <com.bernaferrari.emojislider.EmojiSlider android:id="@+id/slider" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="72dp" /> <View android:id="@+id/slider_particle_system" android:layout_width="match_parent" android:layout_height="match_parent" /> </FrameLayout>
Step 3: control EmojiSlider using in android source code
// Java final EmojiSlider slider = findViewById(R.id.slider); slider.setStartTrackingListener(new Function0<Unit>() { @Override public Unit invoke() { Log.d("D", "setBeginTrackingListener"); return Unit.INSTANCE; } }); slider.setStopTrackingListener(new Function0<Unit>() { @Override public Unit invoke() { Log.d("D", "setEndTrackingListener"); return Unit.INSTANCE; } }); // Or Java 8 lambda slider.setPositionListener(pos -> { Log.d("D", "setPositionListener"); return Unit.INSTANCE; });
In this code, we use findViewById(R.id.slider) to get a EmojiSlider object.
Run this code, you may see: