java中swatch_Java Swatch類代碼示例

本文整理匯總了Java中android.support.v7.graphics.Palette.Swatch類的典型用法代碼示例。如果您正苦於以下問題:Java Swatch類的具體用法?Java Swatch怎麽用?Java Swatch使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

Swatch類屬於android.support.v7.graphics.Palette包,在下文中一共展示了Swatch類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: animateColors

​點讚 3

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

@TargetApi(VERSION_CODES.HONEYCOMB)

private void animateColors(Palette palette) {

int color = palette.getVibrantColor(defaultColor);

Swatch swatch = palette.getMutedSwatch();

anims = new AnimatorSet();

ValueAnimator cardBG = ValueAnimator.ofObject(new ArgbEvaluator(),

defaultColor/* cannot retrieve card BG */, color);

cardBG.addUpdateListener(new AnimatorUpdateListener() {

@Override public void onAnimationUpdate(ValueAnimator animation) {

holder.card.setCardBackgroundColor((Integer)animation.getAnimatedValue());

}

});

anims.play(cardBG);

if (swatch != null) {

ObjectAnimator textColorBG = ofObject(holder.titleView, "backgroundColor", new ArgbEvaluator(),

((ColorDrawable)holder.titleView.getBackground()).getColor(), swatch.getRgb());

ObjectAnimator textColor = ofObject(holder.titleView, "textColor", new ArgbEvaluator(),

holder.titleView.getCurrentTextColor(), swatch.getTitleTextColor());

anims.play(textColor);

anims.play(textColorBG);

}

anims.playTogether(anims.getChildAnimations());

anims.setDuration(3000);

anims.start();

}

開發者ID:TWiStErRob,項目名稱:glide-support,代碼行數:27,

示例2: setupDynamicColor

​點讚 3

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private void setupDynamicColor(Bitmap resource) {

Palette.from(resource).generate(new Palette.PaletteAsyncListener() {

@Override

public void onGenerated(Palette palette) {

Swatch darkVibrantSwatch = palette.getDarkVibrantSwatch();

Swatch darkMutedSwatch = palette.getDarkMutedSwatch();

Swatch lightVibrantSwatch = palette.getLightVibrantSwatch();

Swatch lightMutedSwatch = palette.getLightMutedSwatch();

Swatch backgroundAndContentColors = darkVibrantSwatch;

if (backgroundAndContentColors == null) {

backgroundAndContentColors = darkMutedSwatch;

}

Swatch titleAndFabColors = lightVibrantSwatch;

if (titleAndFabColors == null) {

titleAndFabColors = lightMutedSwatch;

}

setDarkColorWork(backgroundAndContentColors);

setLightColorWork(titleAndFabColors);

}

});

}

開發者ID:amrendra18,項目名稱:udacity-p2,代碼行數:24,

示例3: setDarkColorWork

​點讚 3

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private void setDarkColorWork(Swatch swatch) {

if (swatch != null) {

int color = swatch.getRgb();

mStatusBarColor = color;

// butterknife is throwing NPEs, so have to perform null check

if (titleLists != null) {

ButterKnife.apply(titleLists, titleTextColorChange, color);

}

if (dividerLists != null) {

ButterKnife.apply(dividerLists, dividerColorChange, color);

}

floatingFavouriteActionButton.setBackgroundTintList(ColorStateList.valueOf(color));

floatingShareActionButton.setBackgroundTintList(ColorStateList.valueOf(color));

mToolbar.setBackgroundColor(color);

mCollapsingToolbar.setStatusBarScrimColor(color);

}

}

開發者ID:amrendra18,項目名稱:udacity-p2,代碼行數:22,

示例4: setLightColorWork

​點讚 3

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private void setLightColorWork(Swatch swatch) {

if (swatch != null) {

int color = swatch.getRgb();

toolbarHeaderView.getTitle().setTextColor(color);

toolbarHeaderView.getSubTitle().setTextColor(color);

detailContainer.setBackgroundColor(color);

changeBackgroundColorEvent(color);

floatingFavouriteActionButton.setRippleColor(color);

floatingShareActionButton.setRippleColor(color);

reviewAuthorColor = swatch.getBodyTextColor();

reviewContentColor = swatch.getBodyTextColor();

if (extraDetailsList != null) {

ButterKnife.apply(extraDetailsList, titleTextColorChange, color);

}

if (contentLists != null) {

ButterKnife.apply(contentLists, titleTextColorChange, reviewContentColor);

}

paintAllReviews(reviewsContainer);

}

}

開發者ID:amrendra18,項目名稱:udacity-p2,代碼行數:23,

示例5: getAverageColor

​點讚 3

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

/**

* @return the average color of this box.

*/

Swatch getAverageColor() {

int redSum = 0;

int greenSum = 0;

int blueSum = 0;

int totalPopulation = 0;

for (int i = mLowerIndex; i <= mUpperIndex; i++) {

final int color = mColors[i];

final int colorPopulation = mColorPopulations.get(color);

totalPopulation += colorPopulation;

redSum += colorPopulation * Color.red(color);

greenSum += colorPopulation * Color.green(color);

blueSum += colorPopulation * Color.blue(color);

}

final int redAverage = Math.round(redSum / (float) totalPopulation);

final int greenAverage = Math.round(greenSum / (float) totalPopulation);

final int blueAverage = Math.round(blueSum / (float) totalPopulation);

return new Swatch(redAverage, greenAverage, blueAverage, totalPopulation);

}

開發者ID:vmagro,項目名稱:Palette-Service,代碼行數:26,

示例6: setColors

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private void setColors(Palette palette) {

int color = palette.getVibrantColor(defaultColor);

Swatch swatch = palette.getMutedSwatch();

holder.card.setCardBackgroundColor(color);

if (swatch != null) {

holder.titleView.setBackgroundColor(swatch.getRgb());

holder.titleView.setTextColor(swatch.getTitleTextColor());

}

}

開發者ID:TWiStErRob,項目名稱:glide-support,代碼行數:11,

示例7: quantizePixels

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private List quantizePixels(int maxColorIndex, int maxColors) {

// Create the priority queue which is sorted by volume descending. This means we always

// split the largest box in the queue

final PriorityQueue pq = new PriorityQueue(maxColors, VBOX_COMPARATOR_VOLUME);

// To start, offer a box which contains all of the colors

pq.offer(new Vbox(0, maxColorIndex));

// Now go through the boxes, splitting them until we have reached maxColors or there are no

// more boxes to split

splitBoxes(pq, maxColors);

// Finally, return the average colors of the color boxes

return generateAverageColors(pq);

}

開發者ID:vmagro,項目名稱:Palette-Service,代碼行數:16,

示例8: generateAverageColors

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private List generateAverageColors(Collection vboxes) {

ArrayList colors = new ArrayList(vboxes.size());

for (Vbox vbox : vboxes) {

Swatch color = vbox.getAverageColor();

if (!shouldIgnoreColor(color)) {

// As we're averaging a color box, we can still get colors which we do not want, so

// we check again here

colors.add(color);

}

}

return colors;

}

開發者ID:vmagro,項目名稱:Palette-Service,代碼行數:13,

示例9: setBackground

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private void setBackground(View view, Swatch swatch) {

if (swatch == null) {

view.setBackgroundDrawable(null);

return;

}

view.setBackgroundColor(swatch.getRgb());

}

開發者ID:hoombar,項目名稱:android-training,代碼行數:8,

示例10: getQuantizedColors

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

/**

* @return the list of quantized colors

*/

List getQuantizedColors() {

return mQuantizedColors;

}

開發者ID:vmagro,項目名稱:Palette-Service,代碼行數:7,

示例11: shouldIgnoreColor

​點讚 2

import android.support.v7.graphics.Palette.Swatch; //導入依賴的package包/類

private static boolean shouldIgnoreColor(Swatch color) {

return shouldIgnoreColor(color.getHsl());

}

開發者ID:vmagro,項目名稱:Palette-Service,代碼行數:4,

注:本文中的android.support.v7.graphics.Palette.Swatch類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值