当前位置: 首页>>代码示例>>Java>>正文


Java ColorDrawable.setColor方法代码示例

本文整理汇总了Java中android.graphics.drawable.ColorDrawable.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java ColorDrawable.setColor方法的具体用法?Java ColorDrawable.setColor怎么用?Java ColorDrawable.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.ColorDrawable的用法示例。


在下文中一共展示了ColorDrawable.setColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBgColor

import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
private static Drawable createBgColor(Context context, @ColorInt int resBackgroundColor, @PressedMode.Mode int mode, @FloatRange(from = 0.0f, to = 1.0f) float alpha) {
    ColorDrawable colorDrawableNormal = new ColorDrawable();
    ColorDrawable colorDrawablePressed = new ColorDrawable();
    ColorDrawable colorDrawableUnable = new ColorDrawable();

    colorDrawableNormal.setColor(resBackgroundColor);
    colorDrawablePressed.setColor(resBackgroundColor);
    colorDrawableUnable.setColor(resBackgroundColor);
    Drawable pressed = getPressedStateDrawable(context, mode, alpha, colorDrawablePressed);
    Drawable unable = getUnableStateDrawable(context, colorDrawableUnable);

    return createStateListDrawable(colorDrawableNormal, pressed, unable);
}
 
开发者ID:maoruibin,项目名称:OneDrawable,代码行数:14,代码来源:OneDrawable.java

示例2: setDrawableColor

import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
static void setDrawableColor(Drawable drawable, int color) {
    drawable.mutate();
    if (drawable instanceof ShapeDrawable) {
        ShapeDrawable shapeDrawable = (ShapeDrawable) drawable;
        shapeDrawable.getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        GradientDrawable gradientDrawable = (GradientDrawable) drawable;
        gradientDrawable.setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        ColorDrawable colorDrawable = (ColorDrawable) drawable;
        colorDrawable.setColor(color);
    }

}
 
开发者ID:MAXDeliveryNG,项目名称:slideview,代码行数:15,代码来源:Util.java

示例3: background

import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
@ProtoMethod(description = "Changes the title bar color", example = "")
@ProtoMethodParam(params = {"r", "g", "b", "alpha"})
public PToolbar background(int r, int g, int b, int alpha) {
    int c = Color.argb(alpha, r, g, b);

    ColorDrawable d = new ColorDrawable();
    d.setColor(c);
    mToolbar.setBackgroundDrawable(d);

    return this;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:12,代码来源:PToolbar.java

示例4: setToolbarBackgroundColor

import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
public void setToolbarBackgroundColor(int colorRes) {
    if (mToolbar != null) {
        ColorDrawable background = (ColorDrawable) mToolbar.getBackground();
        background.setColor(getResources().getColor(colorRes));
    }
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:7,代码来源:ToolbarActivity.java

示例5: setEditMode

import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
/**
 * Updates the ActionBar background color depending on whether we are in edit mode or not.
 * 
 * @param editMode
 *            <code>true</code> to show edit mode, <code>false</code> otherwise
 * @param change
 *            if <code>true</code> the background will change with animation, otherwise immediately
 */
@SuppressLint("NewApi")
private void setEditMode(final boolean editMode, final boolean change) {
	mEditMode = editMode;
	mConfigurationListener.setEditMode(editMode);
	if (!change) {
		final ColorDrawable color = new ColorDrawable();
		int darkColor = 0;
		if (editMode) {
			color.setColor(getResources().getColor(R.color.orange));
			darkColor = getResources().getColor(R.color.dark_orange);
		} else {
			color.setColor(getResources().getColor(R.color.actionBarColor));
			darkColor = getResources().getColor(R.color.actionBarColorDark);
		}
		getSupportActionBar().setBackgroundDrawable(color);

		// Since Lollipop the status bar color may also be changed
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
			getWindow().setStatusBarColor(darkColor);
	} else {
		final TransitionDrawable transition = (TransitionDrawable) getResources().getDrawable(
				editMode ? R.drawable.start_edit_mode : R.drawable.stop_edit_mode);
		transition.setCrossFadeEnabled(true);
		getSupportActionBar().setBackgroundDrawable(transition);
		transition.startTransition(200);

		// Since Lollipop the status bar color may also be changed
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			final int colorFrom = getResources().getColor(editMode ? R.color.actionBarColorDark : R.color.dark_orange);
			final int colorTo = getResources().getColor(!editMode ? R.color.actionBarColorDark : R.color.dark_orange);

			final ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
			anim.setDuration(200);
			anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
				@Override
				public void onAnimationUpdate(final ValueAnimator animation) {
					getWindow().setStatusBarColor((Integer) animation.getAnimatedValue());
				}
			});
			anim.start();
		}

		if (mSlider != null && editMode) {
			mSlider.closePane();
		}
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:56,代码来源:UARTActivity.java


注:本文中的android.graphics.drawable.ColorDrawable.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。