一个强大的颜色选择控件。
repositories {
mavenCentral() // or jcenter() works as well
}
dependencies {
compile 'com.github.skydoves:multicolorpicker:1.0.5'
}
<dependency>
<groupId>com.github.skydoves</groupId>
<artifactId>multicolorpicker</artifactId>
<version>1.0.5</version>
</dependency>
xml
<com.skydoves.multicolorpicker.MultiColorPickerView
android:id="@+id/multiColorPickerView"
android:layout_width="300dp"
android:layout_height="300dp"
app:palette="@drawable/palette"/>
app:palette="@drawable/palette" // set palette image
multiColorPickerView.addSelector(selectorDrawable, new ColorListener() {
@Override
public void onColorSelected(ColorEnvelope envelope) {
int color = envelope.getColor();
int\[\] rgb = envelope.getRgb();
String htmlCode = envelope.getHtmlCode();
// TODO
}
});
Methods | Return | Description |
---|---|---|
addSelector(Drawable drawable, ColorListener listener) | Selector | adds a Selector and returning it |
setPaletteDrawable(Drawable drawable) | void | changes palette's drawable |
getMixedColor(Float ratio(0~1)) | void | returns mixed color from selectors seleted color |
setSelectedAlpha(Float ratio(0~1) | void | sets active selector's alpha |
getSelectorsSize() | int | returns selectors size |
setFlagView(FlagView flagView) | void | sets a FlagView on colorpicker |
setFlagMode(FlagMode flagmode) | void | sets FlagMode(Always, Last, None) |
setFlagFlipable(boolean flipable) | void | sets flag's flip-able when flag go over top boundary |
Methods | Return | Description |
---|---|---|
getX() | int | returns selector's X axis |
getY() | int | returns selector's Y axis |
getColor() | int | returns the selector's selected color |
getColorHtml() | String | returns the selector's selected color html code |
getColorRGB() | int[3] | returns the selector's selected color rgb array |
onMove(int x, int y) | void | moves the selector's point |
onMoveCenter() | void | moves the selector's point to center |
onSelect() | void | selects point at selector's position (used with onMove()) |
onSelect(int x, int y) | void | moves and selects point |
本站文章用于学习交流
新浪微博 | QQ群1:161644793qq | QQ群2:98711210
网站地图 | 网站统计
Copyright 2011 - 2021 paocode.com All Rights Reversed. 浙ICP备19041980号
瞎猫内容中心