本文整理汇总了Java中com.gc.materialdesign.utils.Utils.dipOrDpToFloat方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.dipOrDpToFloat方法的具体用法?Java Utils.dipOrDpToFloat怎么用?Java Utils.dipOrDpToFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gc.materialdesign.utils.Utils
的用法示例。
在下文中一共展示了Utils.dipOrDpToFloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: setAttributes
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
super.setAttributes(attrs);
if (!isInEditMode()) {
getBackground().setAlpha(0);
}
iSchecked = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "checked", false);
eventCheck = iSchecked;
//添加监听器,如果点击了这个控件(不包括ball的区域),这个控件就开始判断是否是开启状态。
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
setChecked(iSchecked ? false : true);
}
});
float size = 20;
String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
if (thumbSize != null) {
size = Utils.dipOrDpToFloat(thumbSize);
}
ball = new Ball(getContext());
setThumbParams(size);
addView(ball);
// 给圆球添加监听器,点击圆球后就开始判断是否进入开启状态
ball.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO 自动生成的方法存根
setChecked(iSchecked ? false : true);
}
});
}
示例4: setAttributes
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
super.setAttributes(attrs);
if (!isInEditMode()) {
getBackground().setAlpha(0);
}
showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"showNumberIndicator", false);
min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 100);// max > min
value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);
float size = 20;
String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
if (thumbSize != null) {
size = Utils.dipOrDpToFloat(thumbSize);
}
ball = new Ball(getContext());
setBallParams(size);
addView(ball);
// Set if slider content number indicator
if (showNumberIndicator) {
if (!isInEditMode()) {
numberIndicator = new NumberIndicator(getContext());
}
}
}
示例5: setAttributes
import com.gc.materialdesign.utils.Utils; //导入方法依赖的package包/类
@Override
protected void setAttributes(AttributeSet attrs) {
// TODO 自动生成的方法存根
super.setAttributes(attrs);
float size = 4;// default ring width
String width = attrs.getAttributeValue(MATERIALDESIGNXML, "ringWidth");
if (width != null) {
size = Utils.dipOrDpToFloat(width);
}
ringWidth = size;
}