本文整理汇总了Java中android.graphics.drawable.ColorDrawable.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java ColorDrawable.getColor方法的具体用法?Java ColorDrawable.getColor怎么用?Java ColorDrawable.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.ColorDrawable
的用法示例。
在下文中一共展示了ColorDrawable.getColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFinishInflate
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTextAndBackground = (ViewGroup) findViewById(R.id.text_and_background);
ColorDrawable colorBackground = (ColorDrawable) mTextAndBackground.getBackground();
mBackgroundColor = colorBackground.getColor();
RippleDrawable rippleBackground = new RippleDrawable(ColorStateList.valueOf(
ThemeUtils.getAttrColor(getContext(), android.R.attr.colorControlHighlight)),
colorBackground, null);
mTextAndBackground.setBackground(rippleBackground);
mTitleView = (TextView) mTextAndBackground.findViewById(R.id.title);
mTextView = (TextView) mTextAndBackground.findViewById(R.id.text);
}
示例2: onChangedTextColor
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
public void onChangedTextColor(View view) {
Drawable background = view.getBackground();
ColorDrawable colorDrawable = (ColorDrawable) background;
switch (curSelect) {
case SELECT_TEXTS:
if (null != curCellInfo) {
curCellInfo.textColor = colorDrawable.getColor();
table.updateData(curCellInfo);
} else if (null != curMergeInfo) {
curMergeInfo.textColor = colorDrawable.getColor();
table.updateMergeData(curMergeInfo);
}
break;
case SELECT_BG:
if (null != curCellInfo) {
curCellInfo.bgColor = colorDrawable.getColor();
table.updateData(curCellInfo);
} else if (null != curMergeInfo) {
curMergeInfo.bgColor = colorDrawable.getColor();
table.updateMergeData(curMergeInfo);
}
break;
case SELECT_STROKE:
table.setStrokeColor(colorDrawable.getColor());
table.reset();
break;
case SELECT_OUT_STROKE:
table.setOutStrokeColor(colorDrawable.getColor());
table.reset();
break;
}
}
示例3: updateBackground
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
public void updateBackground(int mainBC, int vicBC, @Nullable SongInfo info) {
PlayBackgroundModeEnum bgMode = playPreference.getPlayBgMode();
switch (bgMode) {
case GRADIENT_COLOR: {
isBg.setVisibility(View.GONE);
GradientDrawable drawable = new GradientDrawable(
GradientDrawable.Orientation.TR_BL,
new int[]{mainBC, vicBC}
);
flRootView.setBackground(drawable);
break;
}
case COLOR: {
isBg.setVisibility(View.GONE);
ColorDrawable cd = (ColorDrawable) flRootView.getBackground();
if (cd != null) {
if (cd.getColor() != mainBC) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
AnimationUtils.startColorGradientAnim(1000, flRootView, null, cd.getColor(), mainBC);
} else {
flRootView.setBackgroundColor(mainBC);
}
}
} else {
flRootView.setBackgroundColor(mainBC);
}
break;
}
default: {
if (info != null) {
isBg.setVisibility(View.VISIBLE);
updateBackgroundDrawable(bgMode, info);
}
break;
}
}
}
示例4: init
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
if (attrs != null) {
TypedArray typedArray = getContext().obtainStyledAttributes(attrs
, R.styleable.DownloadButton);
mTxtSize = typedArray.getDimension(R.styleable.DownloadButton_DownloadButton_textSize
, DEFAULT_TEXT_SIZE);
mTxtColor = typedArray.getColor(R.styleable.DownloadButton_DownloadButton_textColor
, DEFAULT_TEXT_COLOR);
mProgressColor = typedArray.getColor(R.styleable.DownloadButton_DownloadButton_progressColor
, Color.parseColor(DEFAULT_PROGRESS_COLOR));
mRadius = typedArray.getInteger(R.styleable.DownloadButton_DownloadButton_radius, DEFAULT_RADIUS);
mBgColor = typedArray.getColor(R.styleable.DownloadButton_DownloadButton_backgroundColor
, Color.parseColor(DEFAULT_BACKGROUND_COLOR));
}
ColorDrawable drawable = ((ColorDrawable) getBackground());
if (drawable != null) {
mBgColor = drawable.getColor();
mRadius = 0;
}
mTxtPaint = new Paint();
mTxtPaint.setAntiAlias(true);
mTxtPaint.setTextSize(mTxtSize);
mTxtPaint.setTextAlign(Paint.Align.CENTER);
mTxtPaint.setColor(mTxtColor);
mBgPaint = new Paint();
mBgPaint.setAntiAlias(true);
mBgPaint.setStrokeCap(Paint.Cap.ROUND);
mBgPaint.setStyle(Paint.Style.FILL);
mTickPaint = new Paint();
mTickPaint.setAntiAlias(true);
mTickPaint.setColor(mTxtColor);
mTickPaint.setStrokeCap(Paint.Cap.ROUND);
mTickPaint.setStyle(Paint.Style.STROKE);
//path
mLeftPath = new Path();
mRightPath = new Path();
}
示例5: shotRecyclerView
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
/**
* RecyclerView截图
*/
public static Bitmap shotRecyclerView(RecyclerView view, int bgColor, int count) {
RecyclerView.Adapter adapter = view.getAdapter();
Bitmap bigBitmap = null;
if (adapter != null) {
int size = Math.min(count, adapter.getItemCount());
int height = 0;
Paint paint = new Paint();
int iHeight = 0;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
// Use 1/8th of the available memory for this memory cache.
final int cacheSize = maxMemory / 8;
LruCache<String, Bitmap> bitmapCache = new LruCache<>(cacheSize);
for (int i = 0; i < size; i++) {
RecyclerView.ViewHolder holder = adapter.createViewHolder(view, adapter.getItemViewType(i));
adapter.onBindViewHolder(holder, i);
holder.itemView.measure(
View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
holder.itemView.layout(0, 0, holder.itemView.getMeasuredWidth(),
holder.itemView.getMeasuredHeight());
holder.itemView.setDrawingCacheEnabled(true);
holder.itemView.buildDrawingCache();
Bitmap drawingCache = holder.itemView.getDrawingCache();
if (drawingCache != null) {
bitmapCache.put(String.valueOf(i), drawingCache);
}
height += holder.itemView.getMeasuredHeight();
}
bigBitmap = Bitmap.createBitmap(view.getMeasuredWidth(), height, Bitmap.Config.ARGB_8888);
Canvas bigCanvas = new Canvas(bigBitmap);
bigCanvas.drawColor(bgColor);
Drawable lBackground = view.getBackground();
if (lBackground instanceof ColorDrawable) {
ColorDrawable lColorDrawable = (ColorDrawable) lBackground;
int lColor = lColorDrawable.getColor();
bigCanvas.drawColor(lColor);
}
for (int i = 0; i < size; i++) {
Bitmap bitmap = bitmapCache.get(String.valueOf(i));
bigCanvas.drawBitmap(bitmap, 0f, iHeight, paint);
iHeight += bitmap.getHeight();
bitmap.recycle();
}
}
return bigBitmap;
}
示例6: fromColorDrawable
import android.graphics.drawable.ColorDrawable; //导入方法依赖的package包/类
/**
* Creates a new instance of RoundedColorDrawable from the given ColorDrawable.
* @param colorDrawable color drawable to extract the color from
* @return a new RoundedColorDrawable
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static RoundedColorDrawable fromColorDrawable(ColorDrawable colorDrawable) {
return new RoundedColorDrawable(colorDrawable.getColor());
}