本文整理汇总了Java中com.gc.materialdesign.utils.Utils.dpToPx方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.dpToPx方法的具体用法?Java Utils.dpToPx怎么用?Java Utils.dpToPx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gc.materialdesign.utils.Utils
的用法示例。
在下文中一共展示了Utils.dpToPx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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();
}
}
示例7: onDraw
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (numberIndicatorResize == false) {
LayoutParams params = (LayoutParams) numberIndicator.numberIndicator
.getLayoutParams();
params.height = (int) finalSize * 2;
params.width = (int) finalSize * 2;
numberIndicator.numberIndicator.setLayoutParams(params);
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(backgroundColor);
if (animate) {
if (y == 0)
y = finalY + finalSize * 2;
y -= Utils.dpToPx(6, getResources());
size += Utils.dpToPx(2, getResources());
}
canvas.drawCircle(
ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball.getParent())
+ ball.getWidth() / 2, y, size, paint);
if (animate && size >= finalSize)
animate = false;
if (animate == false) {
ViewHelper
.setX(numberIndicator.numberIndicator,
(ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball
.getParent()) + ball.getWidth() / 2)
- size);
ViewHelper.setY(numberIndicator.numberIndicator, y - size);
numberIndicator.numberIndicator.setText(getNumberIndicatorValue(value));
}
invalidate();
}
示例8: ButtonIcon
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
public ButtonIcon(Context context, AttributeSet attrs) {
super(context, attrs);
try {
setBackground(new ColorDrawable(getResources().getColor(R.color.transparent)));
} catch (NoSuchMethodError e) {
setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparent)));
}
rippleSpeed = Utils.dpToPx(2, getResources());
rippleSize = Utils.dpToPx(5, getResources());
}
示例9: onDraw
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (x != -1) {
Rect src = new Rect(0, 0, getWidth(), getHeight());
Rect dst = new Rect(Utils.dpToPx(1, getResources()), Utils.dpToPx(2, getResources()), getWidth()-Utils.dpToPx(1, getResources()), getHeight()-Utils.dpToPx(2, getResources()));
canvas.drawBitmap(cropCircle(makeCircle()), src, dst, null);
invalidate();
}
}
示例10: setDefaultProperties
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
protected void setDefaultProperties(){
rippleSpeed = Utils.dpToPx(2, getResources());
rippleSize = Utils.dpToPx(5, getResources());
setMinimumWidth(Utils.dpToPx(sizeRadius*2, getResources()));
setMinimumHeight(Utils.dpToPx(sizeRadius*2, getResources()));
super.background = R.drawable.background_button_float;
// super.setDefaultProperties();
}
示例11: onDraw
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (numberIndicatorResize == false) {
LayoutParams params = (LayoutParams) numberIndicator.numberIndicator
.getLayoutParams();
params.height = (int) finalSize * 2;
params.width = (int) finalSize * 2;
numberIndicator.numberIndicator.setLayoutParams(params);
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(backgroundColor);
if (animate) {
if (y == 0)
y = finalY + finalSize * 2;
y -= Utils.dpToPx(6, getResources());
size += Utils.dpToPx(2, getResources());
}
canvas.drawCircle(
ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball.getParent())
+ ball.getWidth() / 2, y, size, paint);
if (animate && size >= finalSize)
animate = false;
if (animate == false) {
ViewHelper
.setX(numberIndicator.numberIndicator,
(ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball
.getParent()) + ball.getWidth() / 2)
- size);
ViewHelper.setY(numberIndicator.numberIndicator, y - size);
numberIndicator.numberIndicator.setText(value + "");
}
invalidate();
}
示例12: ButtonIcon
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
public ButtonIcon(Context context, AttributeSet attrs) {
super(context, attrs);
try {
setBackground(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
} catch (NoSuchMethodError e) {
setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
}
rippleSpeed = Utils.dpToPx(2, getResources());
rippleSize = Utils.dpToPx(5, getResources());
}
示例13: ButtonFloatSmall
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
public ButtonFloatSmall(Context context, AttributeSet attrs) {
super(context, attrs);
sizeRadius = 20;
sizeIcon = 20;
setDefaultProperties();
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);
}
示例14: onDraw
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (numberIndicatorResize == false) {
RelativeLayout.LayoutParams params = (LayoutParams) numberIndicator.numberIndicator
.getLayoutParams();
params.height = (int) finalSize * 2;
params.width = (int) finalSize * 2;
numberIndicator.numberIndicator.setLayoutParams(params);
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(backgroundColor);
if (animate) {
if (y == 0)
y = finalY + finalSize * 2;
y -= Utils.dpToPx(6, getResources());
size += Utils.dpToPx(2, getResources());
}
canvas.drawCircle(
ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball.getParent())
+ ball.getWidth() / 2, y, size, paint);
if (animate && size >= finalSize)
animate = false;
if (animate == false) {
ViewHelper
.setX(numberIndicator.numberIndicator,
(ViewHelper.getX(ball)
+ Utils.getRelativeLeft((View) ball
.getParent()) + ball.getWidth() / 2)
- size);
ViewHelper.setY(numberIndicator.numberIndicator, y - size);
numberIndicator.numberIndicator.setText(value + "");
}
invalidate();
}
示例15: onDraw
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (x != -1) {
Rect src = new Rect(0, 0, getWidth(), getHeight());
Rect dst = new Rect(Utils.dpToPx(1, getResources()), Utils.dpToPx(2, getResources()), getWidth()-Utils.dpToPx(1, getResources()), getHeight()-Utils.dpToPx(2, getResources()));
canvas.drawBitmap(cropCircle(makeCircle()), src, dst, null);
}
invalidate();
}