本文整理汇总了Java中android.util.TypedValue.applyDimension方法的典型用法代码示例。如果您正苦于以下问题:Java TypedValue.applyDimension方法的具体用法?Java TypedValue.applyDimension怎么用?Java TypedValue.applyDimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.TypedValue
的用法示例。
在下文中一共展示了TypedValue.applyDimension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAttributes
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Parse the attributes passed to the view from the XML
*
* @param a the attributes to parse
*/
private void parseAttributes(TypedArray a) {
// We transform the default values from DIP to pixels
DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
circleRadius =
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
circleRadius =
(int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
float baseSpinSpeed =
a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
spinSpeed = baseSpinSpeed * 360;
barSpinCycleTime =
a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
spin();
}
// Recycle
a.recycle();
}
示例2: setTextSize
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* @param size in SP units
*/
public void setTextSize(float size) {
mTextSizePx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
size, getResources().getDisplayMetrics());
mTextPaint.setTextSize(mTextSizePx);
mLayout.reflowLines();
invalidate();
requestLayout();
}
示例3: RecognitionScoreView
import android.util.TypedValue; //导入方法依赖的package包/类
public RecognitionScoreView(final Context context, final AttributeSet set) {
super(context, set);
textSizePx =
TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DIP, getResources().getDisplayMetrics());
fgPaint = new Paint();
fgPaint.setTextSize(textSizePx);
bgPaint = new Paint();
bgPaint.setColor(0x12428467);
}
示例4: setDividerPaddingTopBottom
import android.util.TypedValue; //导入方法依赖的package包/类
public void setDividerPaddingTopBottom(int dividerPaddingDp) {
this.dividerPaddingTopBottom = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, dividerPaddingDp, getResources().getDisplayMetrics());
invalidate();
}
示例5: dpToPx
import android.util.TypedValue; //导入方法依赖的package包/类
static float dpToPx(Resources resources, float dp) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
}
示例6: sp2px
import android.util.TypedValue; //导入方法依赖的package包/类
public static int sp2px(@NonNull Context context, int sp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
}
示例7: setup
import android.util.TypedValue; //导入方法依赖的package包/类
private void setup(Context context, AttributeSet attrs) {
mBackgroundPaint = new Paint();
mBackgroundPaint.setColor(Color.WHITE);
mBackgroundPaint.setStyle(Style.FILL);
mTextMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics());
mTextPaintSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics());
mTextPaint = new Paint();
mTextPaint.setColor(Color.BLACK);
mTextPaint.setTextSize(mTextPaintSize);
mAxisPaint = new Paint();
mAxisPaint.setColor(Color.LTGRAY);
mAxisPaint.setStyle(Style.STROKE);
mAxisPaint.setStrokeWidth(GRID_WIDTH);
mGraphPaint = new Paint();
mGraphPaint.setColor(Color.CYAN);
mGraphPaint.setStyle(Style.STROKE);
mGraphPaint.setStrokeWidth(GRAPH_WIDTH);
mDebugPaint = new Paint();
mDebugPaint.setColor(Color.MAGENTA);
mDebugPaint.setStyle(Style.STROKE);
mDebugPaint.setStrokeWidth(GRAPH_WIDTH);
ViewConfiguration vc = ViewConfiguration.get(getContext());
mTouchSlop = vc.getScaledTouchSlop();
mLineMargin = mMinLineMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, getResources().getDisplayMetrics());
zoomReset();
mData = new ArrayList();
if (attrs != null) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GraphView, 0, 0);
setShowGrid(a.getBoolean(R.styleable.GraphView_showGrid, mShowGrid));
setShowInlineNumbers(a.getBoolean(R.styleable.GraphView_showInlineNumbers, mInlineNumbers));
setShowOutline(a.getBoolean(R.styleable.GraphView_showOutline, mShowOutline));
setPanEnabled(a.getBoolean(R.styleable.GraphView_panEnabled, mPanEnabled));
setZoomEnabled(a.getBoolean(R.styleable.GraphView_zoomEnabled, mZoomEnabled));
setBackgroundColor(a.getColor(R.styleable.GraphView_backgroundColor, mBackgroundPaint.getColor()));
setGridColor(a.getColor(R.styleable.GraphView_gridColor, mAxisPaint.getColor()));
setGraphColor(a.getColor(R.styleable.GraphView_graphColor, mGraphPaint.getColor()));
setTextColor(a.getColor(R.styleable.GraphView_numberTextColor, mTextPaint.getColor()));
a.recycle();
}
}
示例8: initView
import android.util.TypedValue; //导入方法依赖的package包/类
private void initView(Context context, AttributeSet attrs) {
this.setOnKeyListener(new NumKeyListener());
this.setFocusable(true);
this.setFocusableInTouchMode(true);
input = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
result = new ArrayList<>();
TypedArray array = context.obtainStyledAttributes(attrs,
R.styleable.SafePswText);
if (array != null) {
pswLength = array.getInt(R.styleable.SafePswText_pswLength, 6);
pswColor = array.getColor(R.styleable.SafePswText_pswColor,
Color.parseColor("#3779e3"));
borderColor = array.getColor(R.styleable.SafePswText_borderColor,
Color.parseColor("#999999"));
inputBorderColor = array.getColor(
R.styleable.SafePswText_inputBorder_color,
Color.parseColor("#3779e3"));
borderShadowColor = array.getColor(
R.styleable.SafePswText_borderShadow_color,
Color.parseColor("#3577e2"));
borderImg = array.getResourceId(R.styleable.SafePswText_borderImg,
R.drawable.pic_dlzc_srk1);
inputBorderImg = array.getResourceId(
R.styleable.SafePswText_inputBorderImg,
R.drawable.pic_dlzc_srk);
isBorderImg = array
.getBoolean(R.styleable.SafePswText_isDrawBorderImg, false);
isShowTextPsw = array
.getBoolean(R.styleable.SafePswText_isShowTextPsw, false);
isShowBorderShadow = array.getBoolean(
R.styleable.SafePswText_isShowBorderShadow, false);
clearTextPsw = array
.getBoolean(R.styleable.SafePswText_clearTextPsw, false);
darkPsw = array.getBoolean(R.styleable.SafePswText_darkPsw, false);
delayTime = array.getInt(R.styleable.SafePswText_delayTime, 1000);
pswTextSize = (int) array
.getDimension(R.styleable.SafePswText_psw_textSize,
TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, 18,
getResources().getDisplayMetrics()));
borderRadius = (int) array
.getDimension(R.styleable.SafePswText_borderRadius,
TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 8,
getResources().getDisplayMetrics()));
} else {
pswLength = 6;
pswColor = Color.parseColor("#3779e3");
borderColor = Color.parseColor("#999999");
inputBorderColor = Color.parseColor("#3779e3");
borderShadowColor = Color.parseColor("#3577e2");
borderImg = R.drawable.pic_dlzc_srk1;
inputBorderImg = R.drawable.pic_dlzc_srk;
delayTime = 1000;
clearTextPsw = false;
darkPsw = false;
isBorderImg = false;
isShowTextPsw = false;
isShowBorderShadow = false;
pswTextSize = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, 18,
getResources().getDisplayMetrics());
}
// The initial width of the border is 40dp
borderWidth = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 40,
getResources().getDisplayMetrics());
// The spacing between frames is 10dp
spacingWidth = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 10,
getResources().getDisplayMetrics());
// The roundness of the border is 8dp
borderRadius = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 0,
getResources().getDisplayMetrics());
borderRectF = new RectF();
initPaint();
}
示例9: dp2px
import android.util.TypedValue; //导入方法依赖的package包/类
public static int dp2px(Context context, float dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
context.getResources().getDisplayMetrics());
}
示例10: dpTodx
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* 单位dp转单位px
*/
public int dpTodx(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
dp, getResources().getDisplayMetrics());
}
示例11: dp2px
import android.util.TypedValue; //导入方法依赖的package包/类
private int dp2px(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
getContext().getResources().getDisplayMetrics());
}
示例12: CustomViewBehind
import android.util.TypedValue; //导入方法依赖的package包/类
public CustomViewBehind(Context context, AttributeSet attrs) {
super(context, attrs);
mMarginThreshold = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
MARGIN_THRESHOLD, getResources().getDisplayMetrics());
}
示例13: dpToPx
import android.util.TypedValue; //导入方法依赖的package包/类
public static int dpToPx(Resources res, int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics());
}
示例14: dpTpPx
import android.util.TypedValue; //导入方法依赖的package包/类
public int dpTpPx(float value) {
DisplayMetrics dm = getResources().getDisplayMetrics();
return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, dm) + 0.5);
}
示例15: dpToPx
import android.util.TypedValue; //导入方法依赖的package包/类
private int dpToPx(Resources res, int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics());
}