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


Java Utils类代码示例

本文整理汇总了Java中com.gc.materialdesign.utils.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makeCircle

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public Bitmap makeCircle() {
	Bitmap output = Bitmap.createBitmap(
			getWidth() - Utils.dpToPx(6, getResources()), getHeight()
					- Utils.dpToPx(7, getResources()), Config.ARGB_8888);
	Canvas canvas = new Canvas(output);
	canvas.drawARGB(0, 0, 0, 0);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor(rippleColor);
	canvas.drawCircle(x, y, radius, paint);
	if (radius > getHeight() / rippleSize)
		radius += rippleSpeed;
	if (radius >= getWidth()) {
		x = -1;
		y = -1;
		radius = getHeight() / rippleSize;
		if (onClickListener != null && clickAfterRipple)
			onClickListener.onClick(this);
	}
	return output;
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:22,代码来源:Button.java

示例2: ButtonFloat

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public ButtonFloat(Context context, AttributeSet attrs) {
	super(context, attrs);
	setBackgroundResource(R.drawable.background_button_float);
	setBackgroundColor(backgroundColor);
	sizeRadius = 28;
	setDefaultProperties();
	icon = new ImageView(context);
	icon.setAdjustViewBounds(true);
	icon.setScaleType(ScaleType.CENTER_CROP);
	if(drawableIcon != null) {
		icon.setImageDrawable(drawableIcon);
	}
	LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
	params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	icon.setLayoutParams(params);
	addView(icon);		
	
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:19,代码来源:ButtonFloat.java

示例3: setAttributes

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
protected void setAttributes(AttributeSet attrs){
	
	setMinimumHeight(Utils.dpToPx(32, getResources()));
	setMinimumWidth(Utils.dpToPx(32, getResources()));
	
	//Set background Color
	// Color by resource
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
		if (background != -1)
			setBackgroundColor(background);
		else
			setBackgroundColor(Color.parseColor("#1E88E5"));
	}
	
	setMinimumHeight(Utils.dpToPx(3, getResources()));
	
				
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:24,代码来源:ProgressBarCircularIndeterminate.java

示例4: ButtonFloat

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public ButtonFloat(Context context, AttributeSet attrs) {
	super(context, attrs);
	setBackgroundResource(R.drawable.background_button_float);
	sizeRadius = 28;
	setDefaultProperties();
	icon = new ImageView(context);
	icon.setAdjustViewBounds(true);
	icon.setScaleType(ScaleType.CENTER_CROP);
	if(drawableIcon != null) {
		icon.setImageDrawable(drawableIcon);
	}
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
	params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	icon.setLayoutParams(params);
	addView(icon);		
	
}
 
开发者ID:GeorgeMe,项目名称:MaterialDesignLibrary,代码行数:18,代码来源:ButtonFloat.java

示例5: onInitAttributes

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
@Override
protected void onInitAttributes(AttributeSet attrs) {
	super.onInitAttributes(attrs);
	// 设置按钮中的图标
	int iconResource = attrs.getAttributeResourceValue(MATERIALDESIGNXML,"iconDrawable",-1);
	if (iconResource != -1) {
		iconDrawable = getResources().getDrawable(iconResource);
	}

	// animation
	boolean animate = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "animate", false);
	if (animate) {
		playAnimation();
	}
	
	if (iconDrawable != null) {
		icon.setBackgroundDrawable(iconDrawable);
	}
	// 设置按钮中图标的大小
	String size = attrs.getAttributeValue(MATERIALDESIGNXML, "iconSize");
	if (size != null) {
		iconSize = (int) Utils.dipOrDpToFloat(size);
	}
	setIconParams();
	addView(icon);
}
 
开发者ID:ibiBgOR,项目名称:android-nas-backup,代码行数:27,代码来源:ButtonFloat.java

示例6: ButtonFloat

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public ButtonFloat(Context context, AttributeSet attrs) {
		super(context, attrs);
		setBackgroundResource(R.drawable.background_button_float);
		sizeRadius = 28;
		setDefaultProperties();
		icon = new ImageView(context);
		icon.setAdjustViewBounds(true);
		icon.setScaleType(ScaleType.CENTER_CROP);
		if(drawableIcon != null) {
			icon.setImageDrawable(drawableIcon);
//			try {
//				icon.setBackground(drawableIcon);
//			} catch (NoSuchMethodError e) {
//				icon.setBackgroundDrawable(drawableIcon);
//			}
		}
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
		params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
		icon.setLayoutParams(params);
		addView(icon);		
		
	}
 
开发者ID:quangctkm9207,项目名称:screen-corner,代码行数:23,代码来源:ButtonFloat.java

示例7: makeCircle

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public Bitmap makeCircle() {
	Bitmap output = Bitmap.createBitmap(
			getWidth() - Utils.dpToPx(6, getResources()), getHeight()
					- Utils.dpToPx(7, getResources()), Config.ARGB_8888);
	Canvas canvas = new Canvas(output);
	canvas.drawARGB(0, 0, 0, 0);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor(rippleColor);
	canvas.drawCircle(x, y, radius, paint);
	if (radius > getHeight() / rippleSize)
		radius += rippleSpeed;
	if (radius >= getWidth()) {
		x = -1;
		y = -1;
		radius = getHeight() / rippleSize;
		if (onClickListener != null)
			onClickListener.onClick(this);
	}
	return output;
}
 
开发者ID:quangctkm9207,项目名称:screen-corner,代码行数:22,代码来源:Button.java

示例8: setAttributes

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
	super.setAttributes(attrs);
	boolean isChecked = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "checked", false);
	if (isChecked) {
		post(new Runnable() {

			@Override
			public void run() {
				setChecked(true);
				setPressed(false);
				changeBackgroundColor(getResources().getColor(android.R.color.transparent));
			}
		});
	}

	float size = 20;
	String checkBoxSize = attrs.getAttributeValue(MATERIALDESIGNXML, "checkBoxSize");
	if (checkBoxSize != null) {
		size = Utils.dipOrDpToFloat(checkBoxSize);
	}
	checkView = new Check(getContext());
	setCheckBoxParams(size);
	addView(checkView);
}
 
开发者ID:ibiBgOR,项目名称:android-nas-backup,代码行数:26,代码来源:CheckBox.java

示例9: ButtonFloat

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public ButtonFloat(Context context, AttributeSet attrs) {
    super(context, attrs);
    setBackgroundResource(R.drawable.background_button_float);
    setBackgroundColor(backgroundColor);
    sizeRadius = 28;
    setDefaultProperties();
    icon = new ImageView(context);
    icon.setAdjustViewBounds(true);
    icon.setScaleType(ScaleType.CENTER_CROP);
    if (drawableIcon != null) {
        icon.setImageDrawable(drawableIcon);
    }
    RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()),
                    Utils.dpToPx(sizeIcon, getResources()));
    params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    icon.setLayoutParams(params);
    addView(icon);

}
 
开发者ID:kurumi-moe,项目名称:MoeGallery,代码行数:21,代码来源:ButtonFloat.java

示例10: setAttributes

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
protected void setAttributes(AttributeSet attrs) {

        setBackgroundResource(R.drawable.background_transparent);

        // Set size of view
        setMinimumHeight(Utils.dpToPx(48, getResources()));
        setMinimumWidth(Utils.dpToPx(80, getResources()));

        // Set background Color
        // Color by resource
        int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
                "background", -1);
        if (bacgroundColor != -1) {
			setBackgroundColor(getResources().getColor(bacgroundColor));
		} else {
			// Color by hexadecimal
			int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
			if (background != -1)
				setBackgroundColor(background);
		}

		check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check",
				false);
		eventCheck = check;
		ball = new Ball(getContext());
		RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
				getResources()), Utils.dpToPx(20, getResources()));
		params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
		ball.setLayoutParams(params);
		addView(ball);

	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:33,代码来源:Switch.java

示例11: onDraw

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	if (!placedBall) {
           placeBall();
       }

	// Crop line to transparent effect
       if(null == bitmap) {
           bitmap = Bitmap.createBitmap(canvas.getWidth(),
                   canvas.getHeight(), Bitmap.Config.ARGB_8888);
       }
	Canvas temp = new Canvas(bitmap);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor((eventCheck) ? backgroundColor : Color.parseColor("#B0B0B0"));
	paint.setStrokeWidth(Utils.dpToPx(2, getResources()));
	temp.drawLine(getHeight() / 2, getHeight() / 2, getWidth()
			- getHeight() / 2, getHeight() / 2, paint);
	Paint transparentPaint = new Paint();
	transparentPaint.setAntiAlias(true);
	transparentPaint.setColor(getResources().getColor(
			android.R.color.transparent));
	transparentPaint.setXfermode(new PorterDuffXfermode(
			PorterDuff.Mode.CLEAR));
	temp.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,
			ViewHelper.getY(ball) + ball.getHeight() / 2,
			ball.getWidth() / 2, transparentPaint);

	canvas.drawBitmap(bitmap, 0, 0, new Paint());

	if (press) {
		paint.setColor((check) ? makePressColor() : Color
				.parseColor("#446D6D6D"));
		canvas.drawCircle(ViewHelper.getX(ball) + ball.getWidth() / 2,
				getHeight() / 2, getHeight() / 2, paint);
	}
	invalidate();

}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:41,代码来源:Switch.java

示例12: setDefaultProperties

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
protected void setDefaultProperties(){
	minHeight = 36;
	minWidth = 88;
	rippleSize = 3;
	// Min size
	setMinimumHeight(Utils.dpToPx(minHeight, getResources()));
	setMinimumWidth(Utils.dpToPx(minWidth, getResources()));
	setBackgroundResource(R.drawable.background_transparent);
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:10,代码来源:ButtonFlat.java

示例13: ButtonFloatSmall

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
public ButtonFloatSmall(Context context, AttributeSet attrs) {
	super(context, attrs);
	sizeRadius = 20;
	sizeIcon = 20;
	setDefaultProperties();
	LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
	params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	icon.setLayoutParams(params);
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:10,代码来源:ButtonFloatSmall.java

示例14: setDefaultProperties

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
protected void setDefaultProperties(){
		rippleSpeed = Utils.dpToPx(2, getResources());
		rippleSize = 10;		
		// Min size
		setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources()));
		setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources()));
		// Background shape
		setBackgroundResource(R.drawable.background_button_float);
//		setBackgroundColor(backgroundColor);
	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:11,代码来源:ButtonFloatSmall.java

示例15: onDraw

import com.gc.materialdesign.utils.Utils; //导入依赖的package包/类
@Override
	protected void onDraw(Canvas canvas) {
//		if(!txtCenter)
//		centrarTexto();
		super.onDraw(canvas);
		if (x != -1) {
			Rect src = new Rect(0, 0, getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources()));
			Rect dst = new Rect(Utils.dpToPx(6, getResources()), Utils.dpToPx(6, getResources()), getWidth()-Utils.dpToPx(6, getResources()), getHeight()-Utils.dpToPx(7, getResources()));
			canvas.drawBitmap(makeCircle(), src, dst, null);
			invalidate();
		}
	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:13,代码来源:ButtonRectangle.java


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