Java Code Examples for android.content.res.TypedArray.getDimension()

The following are Jave code examples for showing how to use getDimension() of the android.content.res.TypedArray class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: prismoji-android   File: PrismojiEditText.java   View Source Code Vote up 6 votes
private void init(@Nullable final AttributeSet attrs) {
    if (!isInEditMode()) {
        PrismojiManager.getInstance().verifyInstalled();
    }

    if (attrs == null) {
        emojiSize = (int) getTextSize();
    } else {
        final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.emoji);

        try {
            emojiSize = (int) a.getDimension(R.styleable.emoji_emojiSize, getTextSize());
        } finally {
            a.recycle();
        }
    }

    setText(getText());
}
 
Example 2
Project: TimeLineSample   File: TimeLineView.java   View Source Code Vote up 6 votes
public void init(Context context, AttributeSet attrs) {
    dotRadius = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 8, context.getResources().getDisplayMetrics()
    );
    lineWidth = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 4, context.getResources().getDisplayMetrics()
    );
    if (attrs != null) {
        TypedArray a = context.getTheme().obtainStyledAttributes(
                attrs,
                R.styleable.TimeLineView,
                0, 0);
        try {
            dotRadius = (int) a.getDimension(R.styleable.TimeLineView_dotRadius, dotRadius);
            lineWidth = (int) a.getDimension(R.styleable.TimeLineView_lineWidth, lineWidth);
        } finally {
            a.recycle();
        }
    }

    setOverScrollMode(OVER_SCROLL_NEVER);
    setHasFixedSize(true);
    setLayoutManager(new LinearLayoutManager(getContext()));
}
 
Example 3
Project: JBase   File: FlowViewHorizontal.java   View Source Code Vote up 6 votes
public FlowViewHorizontal(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FlowViewHorizontal);
    bgRadius = ta.getDimension(R.styleable.FlowViewHorizontal_h_bg_radius, 10);
    proRadius = ta.getDimension(R.styleable.FlowViewHorizontal_h_pro_radius, 8);
    lineBgWidth = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_bg_width, 3f);
    bgColor = ta.getColor(R.styleable.FlowViewHorizontal_h_bg_color, Color.parseColor("#cdcbcc"));
    lineProWidth = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_pro_width, 2f);
    proColor = ta.getColor(R.styleable.FlowViewHorizontal_h_pro_color, Color.parseColor("#029dd5"));
    textPadding = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_text_padding, 20);
    timePadding = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_time_padding, 30);
    maxStep = ta.getInt(R.styleable.FlowViewHorizontal_h_max_step, 5);
    textSize = (int) ta.getDimension(R.styleable.FlowViewHorizontal_h_textsize, 20);
    proStep = ta.getInt(R.styleable.FlowViewHorizontal_h_pro_step, 1);
    ta.recycle();
    init();
}
 
Example 4
Project: cwac-crossport   File: DrawerArrowDrawable.java   View Source Code Vote up 6 votes
/**
 * @param context used to get the configuration for the drawable from
 */
public DrawerArrowDrawable(Context context) {
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeJoin(Paint.Join.MITER);
  mPaint.setStrokeCap(Paint.Cap.BUTT);
  mPaint.setAntiAlias(true);

  final TypedArray a = context.getTheme().obtainStyledAttributes(null,
    R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle,
    R.style.Base_Widget_Material_DrawerArrowToggle);

  setColor(a.getColor(R.styleable.DrawerArrowToggle_color, 0));
  setBarThickness(a.getDimension(R.styleable.DrawerArrowToggle_thickness, 0));
  setSpinEnabled(a.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true));
  // round this because having this floating may cause bad measurements
  setGapSize(Math.round(a.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0)));

  mSize = a.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
  // round this because having this floating may cause bad measurements
  mBarLength = Math.round(a.getDimension(R.styleable.DrawerArrowToggle_barLength, 0));
  // round this because having this floating may cause bad measurements
  mArrowHeadLength = Math.round(a.getDimension(
    R.styleable.DrawerArrowToggle_arrowHeadLength, 0));
  mArrowShaftLength = a.getDimension(R.styleable.DrawerArrowToggle_arrowShaftLength, 0);
  a.recycle();
}
 
Example 5
Project: Huochexing12306   File: LinePageIndicator.java   View Source Code Vote up 5 votes
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
Example 6
Project: weex-3d-map   File: ScreenUtil.java   View Source Code Vote up 5 votes
public static int getDisplayHeight(AppCompatActivity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity.getSupportActionBar() != null) {
      int actionbar= activity.getSupportActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}
 
Example 7
Project: Progressbar   File: CircleBarView.java   View Source Code Vote up 5 votes
private void init(Context context,AttributeSet attrs){
    TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.CircleBarView);

    progressColor = typedArray.getColor(R.styleable.CircleBarView_progress_color,Color.GREEN);
    bgColor = typedArray.getColor(R.styleable.CircleBarView_bg_color,Color.GRAY);
    startAngle = typedArray.getFloat(R.styleable.CircleBarView_start_angle,0);
    sweepAngle = typedArray.getFloat(R.styleable.CircleBarView_sweep_angle,360);
    barWidth = typedArray.getDimension(R.styleable.CircleBarView_bar_width,DpOrPxUtils.dip2px(context,10));
    typedArray.recycle();

    progressNum = 0;
    maxNum = 100;
    defaultSize = DpOrPxUtils.dip2px(context,100);
    mRectF = new RectF();

    progressPaint = new Paint();
    progressPaint.setStyle(Paint.Style.STROKE);//只描边,不填充
    progressPaint.setColor(progressColor);
    progressPaint.setAntiAlias(true);//设置抗锯齿
    progressPaint.setStrokeWidth(barWidth);
    progressPaint.setStrokeCap(Paint.Cap.ROUND);//设置画笔为圆角

    bgPaint = new Paint();
    bgPaint.setStyle(Paint.Style.STROKE);//只描边,不填充
    bgPaint.setColor(bgColor);
    bgPaint.setAntiAlias(true);//设置抗锯齿
    bgPaint.setStrokeWidth(barWidth);
    bgPaint.setStrokeCap(Paint.Cap.ROUND);

    anim = new CircleBarAnim();
}
 
Example 8
Project: QiangHongBao   File: RoundedImageView.java   View Source Code Vote up 5 votes
private void init(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView);
    float radius = ta.getDimension(R.styleable.RoundedImageView_roundRadius, 0);
    float radiusLeftTop = ta.getDimension(R.styleable.RoundedImageView_roundRadiusLeftTop, 0);
    float radiusRightTop = ta.getDimension(R.styleable.RoundedImageView_roundRadiusRightTop, 0);
    float radiusRightBottom = ta.getDimension(R.styleable.RoundedImageView_roundRadiusRightBottom, 0);
    float radiusLeftBottom = ta.getDimension(R.styleable.RoundedImageView_roundRadiusLeftBottom, 0);
    isCircle = ta.getBoolean(R.styleable.RoundedImageView_roundRadiusIsCircle, false);
    ta.recycle();

    if (radius != 0) {
        mRadius = new float[] { radius, radius, radius, radius };
    }

    boolean falg = (radiusLeftTop != 0) ? true : false;
    falg = (radiusRightTop != 0) ? true : falg;
    falg = (radiusRightBottom != 0) ? true : falg;
    falg = (radiusLeftBottom != 0) ? true : falg;

    if (falg) {
        mRadius = new float[] { radiusLeftTop, radiusRightTop, radiusRightBottom, radiusLeftBottom };
    }

    mPathFactory = new PathFactory();
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setDither(false);
}
 
Example 9
Project: boohee_v5.6   File: VectorDrawableCompat.java   View Source Code Vote up 5 votes
private void updateStateFromTypedArray(TypedArray a, XmlPullParser parser) throws XmlPullParserException {
    VectorDrawableCompatState state = this.mVectorState;
    VPathRenderer pathRenderer = state.mVPathRenderer;
    state.mTintMode = parseTintModeCompat(TypedArrayUtils.getNamedInt(a, parser, "tintMode", 6, -1), Mode.SRC_IN);
    ColorStateList tint = a.getColorStateList(1);
    if (tint != null) {
        state.mTint = tint;
    }
    state.mAutoMirrored = TypedArrayUtils.getNamedBoolean(a, parser, "autoMirrored", 5, state.mAutoMirrored);
    pathRenderer.mViewportWidth = TypedArrayUtils.getNamedFloat(a, parser, "viewportWidth", 7, pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = TypedArrayUtils.getNamedFloat(a, parser, "viewportHeight", 8, pathRenderer.mViewportHeight);
    if (pathRenderer.mViewportWidth <= 0.0f) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0.0f) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    } else {
        pathRenderer.mBaseWidth = a.getDimension(3, pathRenderer.mBaseWidth);
        pathRenderer.mBaseHeight = a.getDimension(2, pathRenderer.mBaseHeight);
        if (pathRenderer.mBaseWidth <= 0.0f) {
            throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
        } else if (pathRenderer.mBaseHeight <= 0.0f) {
            throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
        } else {
            pathRenderer.setAlpha(TypedArrayUtils.getNamedFloat(a, parser, "alpha", 4, pathRenderer.getAlpha()));
            String name = a.getString(0);
            if (name != null) {
                pathRenderer.mRootName = name;
                pathRenderer.mVGTargetsMap.put(name, pathRenderer);
            }
        }
    }
}
 
Example 10
Project: android-RibbonViews   File: RibbonTag.java   View Source Code Vote up 5 votes
private void setTypeArray(TypedArray typeArray) {
    tag_textSize = typeArray.getInt(R.styleable.RibbonTag_tag_textSize, tag_textSize);
    tag_textColor = typeArray.getColor(R.styleable.RibbonTag_tag_textColor, tag_textColor);
    ribbonColor = typeArray.getColor(R.styleable.RibbonTag_tag_ribbonColor, ribbonColor);
    ribbonRadius = typeArray.getInt(R.styleable.RibbonTag_tag_ribbonRadius, ribbonRadius);
    padding_left = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_left, padding_left);
    padding_top = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_top, padding_top);
    padding_right = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_right, padding_right);
    padding_bottom = typeArray.getDimension(R.styleable.RibbonTag_tag_padding_bottom, padding_bottom);
}
 
Example 11
Project: FlycoTabLayout   File: SlidingTabLayout.java   View Source Code Vote up 5 votes
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);

    mIndicatorStyle = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, STYLE_NORMAL);
    mIndicatorColor = ta.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
    mIndicatorHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_height,
            dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
    mIndicatorWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorMarginRight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
    mIndicatorWidthEqualTitle = ta.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);

    mUnderlineColor = ta.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
    mUnderlineHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, dp2px(0));
    mUnderlineGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, Gravity.BOTTOM);

    mDividerColor = ta.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
    mDividerWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, dp2px(0));
    mDividerPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, dp2px(12));

    mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
    mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
    mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
    mTabWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(20));

    ta.recycle();
}
 
Example 12
Project: Sega   File: ProgressWheel.java   View Source Code Vote up 5 votes
/**
 * 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();
}
 
Example 13
Project: materialprogress   File: ProgressWheel.java   View Source Code Vote up 5 votes
/**
 * 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();
}
 
Example 14
Project: godlibrary   File: WheelView.java   View Source Code Vote up 5 votes
/**
 * 初始化,获取设置的属性
 *
 * @param context
 * @param attrs
 */
private void init(Context context, AttributeSet attrs) {

    TypedArray attribute = context.obtainStyledAttributes(attrs,
            R.styleable.WheelView);
    unitHeight = (int) attribute.getDimension(
            R.styleable.WheelView_unitHight, 32);
    normalFont = attribute.getDimension(
            R.styleable.WheelView_normalTextSize, 14.0f);
    selectedFont = attribute.getDimension(
            R.styleable.WheelView_selectedTextSize, 22.0f);
    itemNumber = attribute.getInt(R.styleable.WheelView_itemNumber, 7);
    normalColor = attribute.getColor(
            R.styleable.WheelView_normalTextColor, 0xff000000);
    selectedColor = attribute.getColor(
            R.styleable.WheelView_selectedTextColor, 0xffff0000);
    lineColor = attribute.getColor(R.styleable.WheelView_lineColor,
            0xff000000);
    bottomLineColor = attribute.getColor(R.styleable.WheelView_bottomLineColor,
            0xffDADADA);
    lineWidth = attribute.getDimension(R.styleable.WheelView_lineHeight, 2f);
    firstLineAndSecondLineSpace = attribute.getDimension(R.styleable.WheelView_firstLineAndSecondLineSpace, 40f);
    maskHight = attribute.getDimension(R.styleable.WheelView_maskHight,
            48.0f);
    noEmpty = attribute.getBoolean(R.styleable.WheelView_noEmpty, true);
    isEnable = attribute
            .getBoolean(R.styleable.WheelView_isEnable, true);
    attribute.recycle();

    controlHeight = itemNumber * unitHeight;

}
 
Example 15
Project: GitHub   File: PullScrollView.java   View Source Code Vote up 5 votes
private void init(Context context, AttributeSet attrs) {
    // set scroll mode
    setOverScrollMode(OVER_SCROLL_NEVER);

    if (null != attrs) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PullScrollView);

        if (ta != null) {
            mHeaderHeight = (int) ta.getDimension(R.styleable.PullScrollView_headerHeight, -1);
            mHeaderVisibleHeight = (int) ta.getDimension(R.styleable
                    .PullScrollView_headerVisibleHeight, -1);
            ta.recycle();
        }
    }
}
 
Example 16
Project: AppFirCloud   File: RoundImageView.java   View Source Code Vote up 5 votes
public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (Build.VERSION.SDK_INT < 18) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RoundImageView, defStyleAttr, 0);
    imageRadius = (int) array.getDimension(R.styleable.RoundImageView_imageRadius, 4);
    imageRadius = dp2px(context, imageRadius);
    imagePosition = array.getInt(R.styleable.RoundImageView_imagePosition, 0);
    array.recycle();
}
 
Example 17
Project: zxing_qrcode_demo   File: ViewfinderView.java   View Source Code Vote up 4 votes
/**
 * 初始化内部框的大小
 *
 * @param context
 * @param attrs
 */
private void initInnerRect(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ViewfinderView);
    // 扫描框距离顶部
    float innerMarginTop = ta.getDimension(R.styleable.ViewfinderView_inner_margintop, -1);
    if (innerMarginTop != -1) {
        CameraManager.FRAME_MARGINTOP = (int) innerMarginTop;
    }
    // 扫描框的宽度
    viewWidth = (int) ta.getDimension(R.styleable.ViewfinderView_inner_width, -1);
    // 扫描框的高度
    viewHeight = (int) ta.getDimension(R.styleable.ViewfinderView_inner_height, -1);
    //扫描框外部背景色
    maskColor = getResources().getColor(ta.getResourceId(R.styleable.ViewfinderView_inner_maskColor, R.color.viewfinder_mask));

    // 扫描框边角颜色
    innercornercolor = getResources().getColor(ta.getResourceId(R.styleable.ViewfinderView_inn_corner_color, R.color.color_45DDDD));
    // 扫描框边角长度 default(20dp)
    innercornerlength = (int) ta.getDimension(R.styleable.ViewfinderView_inn_corner_length, 20f);
    innercornerlength = dip2px(context, innercornerlength);
    // 扫描框边角宽度 default(3dp)
    innercornerwidth = (int) ta.getDimension(R.styleable.ViewfinderView_inn_corner_width, 3f);
    innercornerwidth = dip2px(context, innercornerwidth);

    // 扫描控件
    scanLight = BitmapFactory.decodeResource(getResources(), ta.getResourceId(R.styleable.ViewfinderView_inner_scan_bitmap, R.drawable.scan_light));
    // 扫描速度 default(10)
    SCAN_VELOCITY = ta.getInt(R.styleable.ViewfinderView_inner_scan_speed, 10);
    //是否显示扫描线动画 default(显示扫描线动画true)
    isShowScanLine = ta.getBoolean(R.styleable.ViewfinderView_inner_isShowScanLine, true);
    //扫描线条自身高度 default(4dp)
    scanLineHeight = (int) ta.getDimension(R.styleable.ViewfinderView_inner_scanLineHeight, 4f);
    scanLineHeight = dip2px(context, scanLineHeight);

    //是否展示小圆点 default(展示小圆点true)
    isCircle = ta.getBoolean(R.styleable.ViewfinderView_inner_scan_iscircle, true);
    //数据像素点颜色
    resultPointColor = getResources().getColor(ta.getResourceId(R.styleable.ViewfinderView_inner_result_points, R.color.possible_result_points));

    //显示圆角扫描框(true)还是拐角扫描框(false) default(拐角扫描框false)
    isRoundMode = ta.getBoolean(R.styleable.ViewfinderView_inner_isRoundMode, false);

    //圆角矩形圆角半径
    radius = (int) ta.getDimension(R.styleable.ViewfinderView_in_Radius, 20f);
    radius = dip2px(context, radius);

    ta.recycle();
}
 
Example 18
Project: OneWeather   File: CircleProgress.java   View Source Code Vote up 4 votes
private void initAttrs(AttributeSet attrs) {
    TypedArray typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar);
    antiAlias = typedArray.getBoolean(R.styleable.CircleProgressBar_antiAlias,Constant.ANTI_ALIAS);
    mHint = typedArray.getString(R.styleable.CircleProgressBar_hint);
    mHintColor = typedArray.getColor(R.styleable.CircleProgressBar_hintColor,Color.BLACK);
    mHintSize = typedArray.getDimension(R.styleable.CircleProgressBar_hintSize,Constant.DEFAULT_HINT_SIZE);


    mValue = typedArray.getFloat(R.styleable.CircleProgressBar_value, Constant.DEFAULT_VALUE);
    //内容数值精度格式
    mPrecision = typedArray.getInt(R.styleable.CircleProgressBar_precision, 0);
    mPrecisionFormat = MiscUtil.getPrecisionFormat(mPrecision);
    mValueColor = typedArray.getColor(R.styleable.CircleProgressBar_valueColor, Color.BLACK);
    mValueSize = typedArray.getDimension(R.styleable.CircleProgressBar_valueSize, Constant.DEFAULT_VALUE_SIZE);

    mMaxValue = typedArray.getInt(R.styleable.CircleProgressBar_maxValue, Constant.DEFAULT_MAX_VALUE);
    mMaxAndMinColor = typedArray.getColor(R.styleable.CircleProgressBar_maxAndMinValueColor,Color.GRAY);
    mMaxAndMinSize = typedArray.getDimension(R.styleable.CircleProgressBar_maxAndMinValueSize,Constant.DEFAULT_TEXT_SIZE);
    mMaxAndMinXOffset = typedArray.getFloat(R.styleable.CircleProgressBar_maxAndMinXOffsetPercent,0.70f);
    mMaxAndMinYOffset = typedArray.getFloat(R.styleable.CircleProgressBar_maxAndMinYOffsetPercent,0.90f);


    mUnit = typedArray.getString(R.styleable.CircleProgressBar_unit);
    mUnitColor = typedArray.getColor(R.styleable.CircleProgressBar_unitColor, Color.BLACK);
    mUnitSize = typedArray.getDimension(R.styleable.CircleProgressBar_unitSize, Constant.DEFAULT_UNIT_SIZE);

    mArcWidth = typedArray.getDimension(R.styleable.CircleProgressBar_arcWidth, Constant.DEFAULT_ARC_WIDTH);
    mStartAngle = typedArray.getFloat(R.styleable.CircleProgressBar_startAngle, Constant.DEFAULT_START_ANGLE);
    mSweepAngle = typedArray.getFloat(R.styleable.CircleProgressBar_sweepAngle, Constant.DEFAULT_SWEEP_ANGLE)+2;

    mBgArcColor = typedArray.getColor(R.styleable.CircleProgressBar_bgArcColor, Color.WHITE);
    mBgArcWidth = typedArray.getDimension(R.styleable.CircleProgressBar_bgArcWidth, Constant.DEFAULT_ARC_WIDTH);
    mTextOffsetPercentInRadius = typedArray.getFloat(R.styleable.CircleProgressBar_textOffsetPercentInRadius, 0.43f);

    //mPercent = typedArray.getFloat(R.styleable.CircleProgressBar_percent, 0);
    mAnimTime = typedArray.getInt(R.styleable.CircleProgressBar_animTime, Constant.DEFAULT_ANIM_TIME);


    int gradientArcColors = typedArray.getResourceId(R.styleable.CircleProgressBar_arcColors,0);
    if(gradientArcColors != 0 ){
        int[] gradientColors = getResources().getIntArray(gradientArcColors);
        if(gradientColors.length == 0){//如果渐变色数组为0,则以单色读取
            int color = ContextCompat.getColor(mContext,gradientArcColors);
            mGradientColors = new int[2];
            mGradientColors[0] = color;
            mGradientColors[1] = color;
        }else if(gradientColors.length == 1){//如果只有一种颜色,默认设置为两种相同颜色
            mGradientColors = new int[2];
            mGradientColors[0] = gradientColors[0];
            mGradientColors[1] = gradientColors[0];
        }else {
            mGradientColors = gradientColors;
        }
    }

    typedArray.recycle();
}
 
Example 19
Project: GifEmoji   File: EmoticonTextView.java   View Source Code Vote up 4 votes
private void init(@Nullable final AttributeSet attrs) {
    int mSchedule;
    if (attrs == null) {
        mEmoticonSize = (int) getTextSize();
        mSchedule = 40;
    } else {
        @SuppressLint("CustomViewStyleable")
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.EmoticonTextView);
        mEmoticonSize = (int) a.getDimension(R.styleable.EmoticonTextView_emoticonSize, getTextSize());
        mSchedule = a.getInteger(R.styleable.EmoticonTextView_emoticonSchedule, 40);
        a.recycle();
    }

    Observable
            .interval(mSchedule, TimeUnit.MILLISECONDS)
            .flatMap(new Function<Long, ObservableSource<Long>>() {
                @Override
                public ObservableSource<Long> apply(Long aLong) throws Exception {
                    return Observable.just(aLong);
                }
            })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<Long>() {
                @Override
                public void onSubscribe(Disposable d) {
                }

                @Override
                public void onNext(Long drawable) {
                    invalidate();
                }

                @Override
                public void onError(Throwable e) {
                }

                @Override
                public void onComplete() {
                }
            });
}
 
Example 20
Project: WavePullLayout   File: PullLayout.java   View Source Code Vote up 4 votes
private void init(AttributeSet attrs) {
    //add header
    if (attrs == null) return;
    TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.waveRefreshLayout);

    bgColor = array.getColor(R.styleable.waveRefreshLayout_xy_bgColor, Color.TRANSPARENT);
    waveColor = array.getColor(R.styleable.waveRefreshLayout_xy_waveColor, Color.GRAY);
    float headerHeight = array.getDimension(R.styleable.waveRefreshLayout_xy_headerHeight, mHeaderHeight);
    float pullHeight = array.getDimension(R.styleable.waveRefreshLayout_xy_pullHeight, mPullHeight);
    int textColor = array.getColor(R.styleable.waveRefreshLayout_xy_textColor, Color.GRAY);
    float textSize = array.getDimension(R.styleable.waveRefreshLayout_xy_textSize, dp2px(getContext(), 15));
    int headerLeftImage = array.getResourceId(R.styleable.waveRefreshLayout_xy_headLeftImage, 0);
    int headerRightImage = array.getResourceId(R.styleable.waveRefreshLayout_xy_headRightImage, 0);
    int headerCenterImage = array.getResourceId(R.styleable.waveRefreshLayout_xy_headCenterImage, 0);
    int headerCenterSuccessImage = array.getResourceId(R.styleable.waveRefreshLayout_xy_headCenterSuccessImage, 0);
    mode = array.getInt(R.styleable.waveRefreshLayout_xy_mode,defaultMode);
    mHeaderHeight = headerHeight == 0 ? dp2px(getContext(), 150) : headerHeight;

    mPullHeight = pullHeight == 0 ? dp2px(getContext(), 100) : pullHeight;

    if (mHeadLayout == null) {
        mHeadLayout = new HeaderLayout(getContext(),mode);
        mHeadLayout.setWaveColor(waveColor);
        mHeadLayout.setColor(bgColor);
        mHeadLayout.setTextColor(textColor);
        mHeadLayout.setTextSize(textSize);
        mHeadLayout.setLeftBitmap(BitmapFactory.decodeResource(getResources(), headerLeftImage));
        mHeadLayout.setRightBitmap(BitmapFactory.decodeResource(getResources(), headerRightImage));
        mHeadLayout.setMode(mode);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mHeadLayout.setElevation(getElevation());
        }
        //添加头部
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.TOP | Gravity.CENTER;
        mHeadLayout.setLayoutParams(params);
        Bitmap normal = BitmapFactory.decodeResource(getResources(), headerCenterImage);
        Bitmap success = BitmapFactory.decodeResource(getResources(), headerCenterSuccessImage);
        initCenter(normal, success);
        this.addView(mHeadLayout);
    }
    array.recycle();
}