Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🤯 A slider widget rich in emoji and highly customisable.

License

NotificationsYou must be signed in to change notification settings

bernaferrari/EmojiSlider

Repository files navigation

Sample appSample usage
FirstSec

DownloadCodacy Badge

A custom made SeekBarheavily inspired bythis great widget from Instagram.

💻 Installation

Add a dependency to yourbuild.gradle:

dependencies {    implementation'com.bernaferrari.emojislider:emojislider:0.3.2'}

It is fully stable, but there might be some changes to the API, like improved naming, or some small changes on functions. You can use it fine already.

Download the sample app to experience it.

🤯 Features

  • Customize with xml using custom handy attributes.
  • Customize in your activity, fragment or dialog.
  • Creating new widget programmatically.

😍 Reselection Enabled Sample

UpDown
FirstSec

❕ Basic Usage

Place theEmojiSlider in your layout.

<com.bernaferrari.emojislider.EmojiSliderandroid:id="@+id/slider"android:layout_width="match_parent"android:layout_height="wrap_content"/>

Important: if you want to have the emoji floating above the slider when it is pressed/dragged, you need to supply a view, preferably on the foreground, to be drawn and tell the slider who the view is.Example:

<?xml version="1.0" encoding="utf-8"?><FrameLayoutxmlns: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.EmojiSliderandroid:id="@+id/slider"android:layout_width="match_parent"android:layout_height="match_parent"android:padding="72dp"/><Viewandroid:id="@+id/slider_particle_system"android:layout_width="match_parent"android:layout_height="match_parent"/></FrameLayout>
   findViewById<EmojiSlider>(R.layout.slider).sliderParticleSystem= slider_particle_system

❔ Usage

To track the current position of the slider, set thepositionListener, as shown below:

val slider = findViewById<EmojiSlider>(R.id.slider)slider.positionListener = { p -> Log.d("MainActivity", "current position is: $p" )}

You can also track the beginning and completion of the movement of the slider, using the following properties:startTrackingListener andstopTrackingListener. Examples below:

slider.startTrackingListener = { /* action on slider touched */ }slider.stopTrackingListener = { /* action on slider released */ }

Here is a random example in Kotlin:

// Kotlinval slider= findViewById<EmojiSlider>(R.id.slider)slider.sliderParticleSystem= slider_particle_systemslider.position=0.25fslider.averagePosition=0.75fslider.allowReselection=trueslider.colorStart=Color.REDslider.colorEnd=Color.YELLOWslider.setResultDrawable(profilePictureBitmap)

Here is a random example in Java:

// JavafinalEmojiSliderslider =findViewById(R.id.slider);slider.setStartTrackingListener(newFunction0<Unit>() {@OverridepublicUnitinvoke() {Log.d("D","setBeginTrackingListener");returnUnit.INSTANCE;    }});slider.setStopTrackingListener(newFunction0<Unit>() {@OverridepublicUnitinvoke() {Log.d("D","setEndTrackingListener");returnUnit.INSTANCE;    }});// Or Java 8 lambdaslider.setPositionListener(pos -> {Log.d("D","setPositionListener");returnUnit.INSTANCE;});

Check the sample app for more. The sample app even shows how to use Glide to load a Bitmap into a round drawable.

🎨 Customization and Attributes

All customizable attributes for EmojiSlider:

Attribute NameDefault ValueDescription
app:emoji😍The emoji which will be used on the slider
app:progress_value0.25fInitial position for the progress in range from 0.0 to 1.0.
app:average_progress0.50fInitial position for the average value in range from 0.0 to 1.0.
app:bar_progress_color_start@color/slider_gradient_startColor of the start (left side) of the progress bar.
app:bar_progress_color_end@color/slider_gradient_endColor of the end (right side) of the progress bar
app:bar_track_color@color/slider_trackColor of the bar's track.
app:thumb_size_percent_on_pressed0.9Thumb size automatically shrinks to 90% (0.9) its original size when a touch is detected. This allows to choose another value between 0.0 and 1.0.
app:allow_reselectionfalseShould the slider behave like the original Emoji Slider or like a SeekBar? When true, it behaves like a SeekBar, so average/profile/result will not be shown.
app:is_touch_disabledfalseAllow to disable touch input.
app:should_display_tooltiptrueAllow to disable the tooltip when a value is selected.
app:tooltip_text@string/average_answerThe "average answer" text, translated into 40 languages. You can overwrite it using this.
app:tooltip_dismiss_timer2500The tooltip auto hide after some period, in milliseconds. Choose -1 to disable this timer.
app:should_display_averagetrueAllow to disable the average circle when a value is selected. If this is disabled, tooltip will not be shown even if it is enabled.
app:should_display_averagefalseAllow to disable the round circle that shows up when a value is selected (usually with user's profile picture).
app:register_touches_outside_thumbtrueThe original Emoji Slider only registers touch inside the thumb. The SeekBar register on the bar, too. This allows to choose which best suits you.
app:particle_directionupShould the floating emoji go up or down after finger leaves the bar?

Of course, some attributes might have better names than others and documentation might not be perfect. If you find anything wrong or weird,let me know.

📃 Libraries Used

🦁 Screenshots

FloatingValue Selected
FirstSec
SampleSample
ThirdFourth

Reporting Issues

Issues and Pull Requests are welcome.You can reporthere.

License

Copyright 2018 Bernardo Ferrari.

Licensed to the Apache Software Foundation (ASF) under one or more contributorlicense agreements. See the NOTICE file distributed with this work foradditional information regarding copyright ownership. The ASF licenses thisfile to you under the Apache License, Version 2.0 (the "License"); you may notuse this file except in compliance with the License. You may obtain a copy ofthe License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS, WITHOUTWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See theLicense for the specific language governing permissions and limitations underthe License.

About

🤯 A slider widget rich in emoji and highly customisable.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp