ColorSeekBar


Source link: https://github.com/rtugeek/ColorSeekBar

ColorSeekBar

ScreenShot:

Attrs

attr format default
colorSeeds references
colorBarPosition integer 0
alphaBarPosition integer 0
maxPosition integer 100
bgColor color TRANSPARENT
barHeight dimension 2dp
barMargin dimension 5dp
thumbHeight dimension 30dp
showAlphaBar boolean false
isVertical boolean false

Gradle:

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

  allprojects {

repositories {

 ...
 maven {
 url "https://jitpack.io" 
}

}
  
}
 

Step 2. Add the dependency

  compile 'com.github.rtugeek:ColorSeekBar:1.5.2' 

Usage

XML

  <com.rtugeek.android.colorseekbar.ColorSeekBar

 android:id="@+id/colorSlider"

 android:layout_width="match_parent"

 app:colorSeeds="@array/material_colors"

 android:layout_height="wrap_content" />

JAVA

  colorSeekBar.setMaxPosition(100);

colorSeekBar.setColorSeeds(R.array.material_colors);
 // material_colors is defalut included in res/color,just use it.
colorSeekBar.setColorBarPosition(10);
 //0 - maxValue
colorSeekBar.setAlphaBarPosition(10);
 //0 - 255
colorSeekBar.setShowAlphaBar(true);

colorSeekBar.setBarHeight(5);
 //5dpi
colorSeekBar.setThumbHeight(30);
 //30dpi
colorSeekBar.setBarMargin(10);
 //set the margin between colorBar and alphaBar 10dpi

Listener

  colorSeekBar.setOnColorChangeListener(new ColorSeekBar.OnColorChangeListener() {

 @Override

 public void onColorChangeListener(int colorBarPosition, int alphaBarPosition, int color) {

  textView.setTextColor(color);

  //colorSeekBar.getAlphaValue();


 
}

}
);

Vertical Bar [BETA]

  <com.rtugeek.android.colorseekbar.ColorSeekBar

 android:id="@+id/colorSlider"

 android:layout_width="match_parent"

 app:colorSeeds="@array/material_colors"

 app:isVertical="true"

 android:layout_height="wrap_content" />

getColor() issue

Render flow:
1.Activity->onCreate();
2.Activity->onResume();
3.ColorSeekBar->onMeasure();
4.ColorSeekBar->onSizeChanged();
5.ColorSeekBar->init();
6.ColorSeekBar->onMeasure();
7.ColorSeekBar->onDraw();

getColor()/getColors()/getColorIndexPosition() do not work correct until onDraw() method invoked. So, If you want to get color or something else form ColorSeekBar on Activity.onCreate() function, just do:

 mColorSeekBar.setOnInitDoneListener(new ColorSeekBar.OnInitDoneListener() {

@Override

public void done() {

 mColorSeekBar.getColorIndexPosition(mColor);

 //mColorSeekBar.getColors();


 //mColorSeekBar.getColor();


}

  
}
);

Spread the word

License



  DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

  Version 2, December 2004  Copyright (C) 2004 Leon Fu <[email protected]>  Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO. 

Resources

An Android image processor library providing a variety of transformations for Fresco.

Android MVVM lightweight library.

Implementation of Facebook social plugin 'Like' for Android.

A simple library to add tooltips to your awesome Android application.

BannerTime creates a scheduled popup to show your personal message.

This library runs background service that is listening for shake movements in device.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes