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


Java GradientDrawable.setColor方法代码示例

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


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

示例1: setBackgroundColor

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
public void setBackgroundColor(int color) {
	backgroundColor = color;
	if (isEnabled()) {
		beforeBackground = backgroundColor;
	}
	try {
		LayerDrawable layer = (LayerDrawable) getBackground();
		// 每个按钮的框架都是由drawable中的xml文件制定的,xml文件中都有一个item的id叫:shape_bacground
		GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
		/**
		 * 给这个图片设置背景色,因为图片的主体是透明的所以可以直接显示背景色
		 * 效果就是一个透明但有阴影的框架下有了背景色,这样的方式可以方便的设置不同颜色的按钮,让按钮看起来还是浑然一体
		 */
		shape.setColor(backgroundColor);
		/**
		 * 当重新设定背景色后,要检查涟漪颜色。如果已经设定了涟漪颜色,那么就用之前的。如果没设定就重新生成
		 */
		if (!settedRippleColor) {
			rippleColor = makePressColor(255);
		}
	} catch (Exception ex) {
		// Without bacground
	}
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:26,代码来源:Button.java

示例2: build

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public StateListDrawable build(Context ctx) {
    StateListDrawable stateListDrawable = new StateListDrawable();

    GradientDrawable normal = (GradientDrawable) ContextCompat.getDrawable(ctx, R.drawable.action_item_badge);
    GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();

    normal.setColor(mColor);
    selected.setColor(mColorPressed);

    if (mStroke > -1) {
        normal.setStroke(mStroke, mStrokeColor);
        selected.setStroke(mStroke, mStrokeColor);
    }

    if (mCorners > -1) {
        normal.setCornerRadius(mCorners);
        selected.setCornerRadius(mCorners);
    }

    stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, selected);
    stateListDrawable.addState(StateSet.WILD_CARD, normal);

    return stateListDrawable;
}
 
开发者ID:OmarAliSaid,项目名称:android-paypal-example,代码行数:25,代码来源:BadgeDrawableBuilder.java

示例3: FlatToast

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public FlatToast(Context context) {
    super(context);
    mContext = context;
    
    //toast text
    textView = new TextView(context);
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(17);
    textView.setPadding(Utils.dip2px(context, 15), Utils.dip2px(context, 8), Utils.dip2px(context, 15), Utils.dip2px(context, 8));
    
    //toast background
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(Color.parseColor("#212121"));
    gradientDrawable.setAlpha(200);
    gradientDrawable.setCornerRadius(Utils.dip2px(context, 10));
}
 
开发者ID:AstinPE,项目名称:StarchWindow,代码行数:17,代码来源:FlatToast.java

示例4: updateSelectedColorPreview

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void updateSelectedColorPreview() {

        // Create color with selected color values
        int redValue = seekBarRed.getProgress();
        int greenValue = seekBarGreen.getProgress();
        int blueValue = seekBarBlue.getProgress();
        int alpha = seekBarAlpha.getProgress();

        selectedColor = Color.argb(alpha, redValue, greenValue, blueValue);

        GradientDrawable previewBackground = (GradientDrawable) selectedColorPreview.getBackground();
        previewBackground.setColor(selectedColor);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            selectedColorPreview.setBackground(previewBackground);
        }
        else {
            selectedColorPreview.setBackgroundDrawable(previewBackground);
        }
    }
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:20,代码来源:ColorSelectionView.java

示例5: loadHintView

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 加载hintView的容器
 */
private void loadHintView(){
	addView(mHintView);
	mHintView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
	LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
               ViewGroup.LayoutParams.WRAP_CONTENT);
	lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	((View) mHintView).setLayoutParams(lp);

	GradientDrawable gd = new GradientDrawable();
	gd.setColor(color);
	gd.setAlpha(alpha);
	mHintView.setBackgroundDrawable(gd);

       mHintViewDelegate.initView(mAdapter == null ? 0 : mAdapter.getCount(),
               gravity, (BaseHintView) mHintView);
}
 
开发者ID:yangchong211,项目名称:YCBanner,代码行数:20,代码来源:BannerView.java

示例6: createDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private GradientDrawable createDrawable(int color, int cornerColor, int cornerSize, int cornerRadius) {
    GradientDrawable out = new GradientDrawable();
    out.setColor(color);
    out.setStroke(cornerSize, cornerColor);
    out.setCornerRadius(cornerRadius);
    return out;
}
 
开发者ID:JMaroz,项目名称:RoundButton,代码行数:8,代码来源:RoundButton.java

示例7: onBindViewHolder

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * Called by the RecyclerView to display data at a specified position in the Cursor.
 *
 * @param holder The ViewHolder to bind Cursor data to
 * @param position The position of the data in the Cursor
 */
@Override
public void onBindViewHolder(TaskViewHolder holder, int position) {

    // Indices for the _id, description, and priority columns
    int idIndex = mCursor.getColumnIndex(TaskContract.TaskEntry._ID);
    int descriptionIndex = mCursor.getColumnIndex(TaskContract.TaskEntry.COLUMN_DESCRIPTION);
    int priorityIndex = mCursor.getColumnIndex(TaskContract.TaskEntry.COLUMN_PRIORITY);

    mCursor.moveToPosition(position); // get to the right location in the cursor

    // Determine the values of the wanted data
    final int id = mCursor.getInt(idIndex);
    String description = mCursor.getString(descriptionIndex);
    int priority = mCursor.getInt(priorityIndex);

    //Set values
    holder.itemView.setTag(id);
    holder.taskDescriptionView.setText(description);

    // Programmatically set the text and color for the priority TextView
    String priorityString = "" + priority; // converts int to String
    holder.priorityView.setText(priorityString);

    GradientDrawable priorityCircle = (GradientDrawable) holder.priorityView.getBackground();
    // Get the appropriate background color based on the priority
    int priorityColor = getPriorityColor(priority);
    priorityCircle.setColor(priorityColor);

}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:36,代码来源:CustomCursorAdapter.java

示例8: makeNormalDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
public Drawable makeNormalDrawable() {
    GradientDrawable dot_normal = new GradientDrawable();
    dot_normal.setColor(normalColor);
    dot_normal.setCornerRadius(SizeUtil.dip2px(getContext(), 4));
    dot_normal.setSize(SizeUtil.dip2px(getContext(), 8), SizeUtil.dip2px(getContext(), 8));
    return dot_normal;
}
 
开发者ID:yangchong211,项目名称:YCBanner,代码行数:9,代码来源:ColorPointHintView.java

示例9: changeBackground

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public void changeBackground() {
	if (!isInEditMode()) {
		if (value != min) {
			setBackgroundResource(R.drawable.background_checkbox);
			LayerDrawable layer = (LayerDrawable) getBackground();
			GradientDrawable shape = (GradientDrawable) layer
					.findDrawableByLayerId(R.id.shape_bacground);
			shape.setColor(backgroundColor);
		} else {
			setBackgroundResource(R.drawable.background_switch_ball_uncheck);
		}
	}
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:14,代码来源:Slider.java

示例10: makeFocusDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
public Drawable makeFocusDrawable() {
    GradientDrawable dot_focus = new GradientDrawable();
    dot_focus.setColor(focusColor);
    dot_focus.setCornerRadius(SizeUtil.dip2px(getContext(), 4));
    dot_focus.setSize(SizeUtil.dip2px(getContext(), 8), SizeUtil.dip2px(getContext(), 8));
    return dot_focus;
}
 
开发者ID:yangchong211,项目名称:YCBanner,代码行数:9,代码来源:ColorPointHintView.java

示例11: setupBadgeBackgroundColors

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void setupBadgeBackgroundColors(String BADGE_COLOR) {

        GradientDrawable gd = (GradientDrawable) outer_container.getBackground();
        gd.setColor(Color.parseColor(BADGE_COLOR));

        LayerDrawable layers = (LayerDrawable) bottom_arrow.getBackground();
        RotateDrawable rotate = (RotateDrawable) layers.findDrawableByLayerId(R.id.grad);
        GradientDrawable drawable = (GradientDrawable) rotate.getDrawable();
        drawable.setColor(Color.parseColor(BADGE_COLOR));

    }
 
开发者ID:salRoid,项目名称:InstaBadge,代码行数:12,代码来源:InstaBadgeView.java

示例12: getGradientDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public GradientDrawable getGradientDrawable(int strokeWidth,int strokeColor,int fillColor){
    GradientDrawable gd = new GradientDrawable();//创建drawable
    gd.setColor(fillColor);
    gd.setShape(GradientDrawable.OVAL);
    gd.setSize(100, 100);
    gd.setStroke(strokeWidth, strokeColor);
    return gd;
}
 
开发者ID:yaokantv,项目名称:YKCenterDemo-Android,代码行数:9,代码来源:AnimStudy.java

示例13: makeFocusDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
   public Drawable makeFocusDrawable()
{
       GradientDrawable dot_focus = new GradientDrawable();
       dot_focus.setColor(focusColor);
       dot_focus.setCornerRadius(dump.v.Util.dip2px(getContext(), 4));
       dot_focus.setSize(dump.v.Util.dip2px(getContext(), 8), dump.v.Util.dip2px(getContext(), 8));
       return dot_focus;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:10,代码来源:ColorPointHintView.java

示例14: getBadgeDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
static GradientDrawable getBadgeDrawable(BadgeItem badgeItem, Context context) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadius(context.getResources().getDimensionPixelSize(R.dimen.badge_corner_radius));
    shape.setColor(badgeItem.getBackgroundColor(context));
    shape.setStroke(badgeItem.getBorderWidth(), badgeItem.getBorderColor(context));
    return shape;
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:9,代码来源:BottomNavigationHelper.java

示例15: createGradientDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public static GradientDrawable createGradientDrawable(int radious, int color) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(color);
    drawable.setCornerRadius((float) radious);
    return drawable;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:7,代码来源:UIsUtils.java


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