本文整理汇总了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;
}
示例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);
}
示例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()));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}