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


Java TypedValue.applyDimension方法代码示例

本文整理汇总了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();
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:43,代码来源:ProgressWheel.java

示例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();
}
 
开发者ID:suragch,项目名称:mongol-library,代码行数:12,代码来源:MongolTextView.java

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

示例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();
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:6,代码来源:PagerSlidingTabStrip.java

示例5: dpToPx

import android.util.TypedValue; //导入方法依赖的package包/类
static float dpToPx(Resources resources, float dp) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
}
 
开发者ID:florent37,项目名称:Depth,代码行数:4,代码来源:MaterialMenuDrawable.java

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

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

示例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();
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:81,代码来源:SafePswText.java

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

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

示例11: dp2px

import android.util.TypedValue; //导入方法依赖的package包/类
private int dp2px(int dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
            getContext().getResources().getDisplayMetrics());
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:5,代码来源:BubbleImageView.java

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

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

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:DropDownMenu.java

示例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());
}
 
开发者ID:wanbanjiesan,项目名称:Android-TV-FocusLayout,代码行数:4,代码来源:AnimContainer.java


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