标签:android style http io ar color os 使用 sp
public final class pallete 继承自 Object
java.lang.Object
|_android.supprot.v7.graphics.Palette
Palette从图像中提取突出的颜色,这样可以把色值赋给ActionBar、或者其他,可以让界面整个色调统一.
Palette这个类中提取以下突出的颜色:
Vibrant (有活力)
Vibrant dark(有活力 暗色)
Vibrant light(有活力 亮色)
Muted (柔和)
Muted dark(柔和 暗色)
Muted light(柔和 亮色)
这些都可以通过合适的getteer方法提取。
同步factory方法generate(Bitmap)和generate(Bitmap,int)可以用来创建实例。这些应该在一个后台线程中调用,最完美的就是加载图像的那个线程。有时候这是不可能的,所以异步factory方法也被提出:generateAsync(Bitmap, PaletteAsyncListener)和generateAsync(Bitmap, int, PaletteAsyncListener)。示例如下所示:
Pallete.generateAsync(bitmap,new Palette.PalleteAsyncListener(){ public void onGenerates(Palette palette){ //do something with colors …… } });
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | Palette.PaletteAsyncListener | Listener to be used with generateAsync(Bitmap, PaletteAsyncListener) or generateAsync(Bitmap, int, PaletteAsyncListener) |
|||||||||
class | Palette.Swatch | Represents a color swatch generated from an image‘s palette. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | equals(Object o) Compares this instance with the specified object and indicates if they are equal. |
||||||||||
static Palette | generate(Bitmap bitmap) Generate a |
||||||||||
static Palette | generate(Bitmap bitmap, int numColors) Generate a |
||||||||||
static AsyncTask<Bitmap, Void, Palette> | generateAsync(Bitmap bitmap, int numColors, Palette.PaletteAsyncListener listener) Generate a |
||||||||||
static AsyncTask<Bitmap, Void, Palette> | generateAsync(Bitmap bitmap, Palette.PaletteAsyncListener listener) Generate a |
||||||||||
int | getDarkMutedColor(int defaultColor) Returns a muted and dark color from the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getDarkMutedSwatch() Returns a muted and dark swatch from the palette. |
||||||||||
int | getDarkVibrantColor(int defaultColor) Returns a dark and vibrant color from the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getDarkVibrantSwatch() Returns a dark and vibrant swatch from the palette. |
||||||||||
int | getLightMutedColor(int defaultColor) Returns a muted and light color from the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getLightMutedSwatch() Returns a muted and light swatch from the palette. |
||||||||||
int | getLightVibrantColor(int defaultColor) Returns a light and vibrant color from the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getLightVibrantSwatch() Returns a light and vibrant swatch from the palette. |
||||||||||
int | getMutedColor(int defaultColor) Returns a muted color from the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getMutedSwatch() Returns a muted swatch from the palette. |
||||||||||
List<Palette.Swatch> | getSwatches() Returns all of the swatches which make up the palette. |
||||||||||
int | getVibrantColor(int defaultColor) Returns the most vibrant color in the palette as an RGB packed int. |
||||||||||
Palette.Swatch | getVibrantSwatch() Returns the most vibrant swatch in the palette. |
||||||||||
int | hashCode() Returns an integer hash code for this object. |
public static Pallete generate(Bitmap bitmap) 从Bitmap生成一个Pallete,使用默认的颜色个数
public static Pallete generate(Bitmap bitmap, int numColors) 从Bitmap生成Palette,使用指定的numColors。好的numColors值依图像源而定,风景画一般取12-16之间,对于人脸占大部分的图取值24-32。numColors越大,计算所需的时间越长。
public boolean equals(Object o) 比较该实例与某个实例。默认只有当this == o 时结果是true,否则为false。为了equal,o必须代表与实例同样的对象使用一个类依赖对比。一般约定对比应该是反身的、对称而且可传递的。同时,没有对象引用除了null等于null。如果想实现自己的equals方法,可以参照https://developer.android.com/reference/java/lang/Object.html#writing_equals。
Generate a Palette
asynchronously. onGenerated(Palette)
will be called with the created instance. The resultingPalette
is the same as what would be created by calling generate(Bitmap, int)
.
listener | Listener to be invoked when the Palette has been generated. |
---|
the AsyncTask
used to asynchronously generate the instance.
Generate a Palette
asynchronously. onGenerated(Palette)
will be called with the created instance. The resultingPalette
is the same as what would be created by calling generate(Bitmap)
.
listener | Listener to be invoked when the Palette has been generated. |
---|
the AsyncTask
used to asynchronously generate the instance.
Returns a muted and dark color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns a muted and dark swatch from the palette. Might be null.
Returns a dark and vibrant color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns a dark and vibrant swatch from the palette. Might be null.
Returns a muted and light color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns a muted and light swatch from the palette. Might be null.
Returns a light and vibrant color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns a light and vibrant swatch from the palette. Might be null.
Returns a muted(柔和的)color from the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns a muted swatch from the palette. Might be null.
public List<Palette.Swatch> getSwatches ()
Returns all of the swatches which make up the palette.
Returns the most vibrant color in the palette as an RGB packed int.
defaultColor | value to return if the swatch isn‘t available |
---|
Returns the most vibrant swatch in the palette. Might be null.
Returns an integer hash code for this object. By contract, any two objects for which equals(Object)
returns true
must return the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct hashCode
method if you intend implementing your own hashCode
method.
this object‘s hash code.
标签:android style http io ar color os 使用 sp
原文地址:http://my.oschina.net/liusicong/blog/355285