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


Java Utils.dpToPx方法代码示例

本文整理汇总了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);		
	
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:19,代码来源:ButtonFloat.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);
	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

示例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);

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

示例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);
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:10,代码来源:ButtonFloatSmall.java

示例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);
	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:11,代码来源:ButtonFloatSmall.java

示例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();
		}
	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:13,代码来源:ButtonRectangle.java

示例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();
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:39,代码来源:Slider.java

示例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());
}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:11,代码来源:ButtonIcon.java

示例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();
	}
}
 
开发者ID:JianxunRao,项目名称:FangYanShuo,代码行数:11,代码来源:ButtonFloat.java

示例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();
	}
 
开发者ID:shegang,项目名称:meishiDemo,代码行数:9,代码来源:ButtonFloat.java

示例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();
}
 
开发者ID:JianxunRao,项目名称:FangYanShuo,代码行数:41,代码来源:Slider.java

示例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());
}
 
开发者ID:kurumi-moe,项目名称:MoeGallery,代码行数:11,代码来源:ButtonIcon.java

示例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);
}
 
开发者ID:quangctkm9207,项目名称:screen-corner,代码行数:10,代码来源:ButtonFloatSmall.java

示例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();
}
 
开发者ID:kurumi-moe,项目名称:MoeGallery,代码行数:41,代码来源:Slider.java

示例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();
}
 
开发者ID:quangctkm9207,项目名称:screen-corner,代码行数:11,代码来源:ButtonFloat.java


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