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

The following are Jave code examples for showing how to use getDimensionPixelSize() 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: BezierRoundView   File: BezierRoundView .java   View Source Code Vote up 6 votes
public BezierRoundView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics());  //Ĭ������15dp

    // ��ȡ�Զ�����ʽ����
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BezierRoundView, defStyleAttr, 0);
    color_select = array.getColor(R.styleable.BezierRoundView_color_select, color_select);
    color_touch = array.getColor(R.styleable.BezierRoundView_color_touch, color_touch);
    color_default = array.getColor(R.styleable.BezierRoundView_color_not_select, color_default);
    time_animator = array.getInteger(R.styleable.BezierRoundView_time_animator, time_animator);
    default_round_count = array.getInteger(R.styleable.BezierRoundView_round_count, default_round_count);
    mRadius = array.getDimensionPixelSize(R.styleable.BezierRoundView_radius, mRadius);
    mDistance = array.getDimensionPixelSize(R.styleable.BezierRoundView_distance, mDistance);
    array.recycle();

    init();
}
 
Example 2
Project: Tribe   File: EaseContactList.java   View Source Code Vote up 6 votes
private void init(Context context, AttributeSet attrs) {
    this.context = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EaseContactList);
    primaryColor = ta.getColor(R.styleable.EaseContactList_ctsListPrimaryTextColor, 0);
    primarySize = ta.getDimensionPixelSize(R.styleable.EaseContactList_ctsListPrimaryTextSize, 0);
    showSiderBar = ta.getBoolean(R.styleable.EaseContactList_ctsListShowSiderBar, true);
    initialLetterBg = ta.getDrawable(R.styleable.EaseContactList_ctsListInitialLetterBg);
    initialLetterColor = ta.getColor(R.styleable.EaseContactList_ctsListInitialLetterColor, 0);
    ta.recycle();
    
    
    LayoutInflater.from(context).inflate(R.layout.ease_widget_contact_list, this);
    listView = (ListView)findViewById(R.id.list);
    sidebar = (EaseSidebar) findViewById(R.id.sidebar);
    if(!showSiderBar)
        sidebar.setVisibility(View.GONE);
}
 
Example 3
Project: Alexa-Voice-Service   File: CircleImageView.java   View Source Code Vote up 5 votes
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);

    mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
    mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
    mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
    mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);

    a.recycle();

    init();
}
 
Example 4
Project: xlight_android_native   File: SaturationBar.java   View Source Code Vote up 5 votes
private void init(AttributeSet attrs, int defStyle) {
	final TypedArray a = getContext().obtainStyledAttributes(attrs,
			R.styleable.ColorBars, defStyle, 0);
	final Resources b = getContext().getResources();

	mBarThickness = a.getDimensionPixelSize(
			R.styleable.ColorBars_bar_thickness,
			b.getDimensionPixelSize(R.dimen.bar_thickness));
	mBarLength = a.getDimensionPixelSize(R.styleable.ColorBars_bar_length,
			b.getDimensionPixelSize(R.dimen.bar_length));
	mPreferredBarLength = mBarLength;
	mBarPointerRadius = a.getDimensionPixelSize(
			R.styleable.ColorBars_bar_pointer_radius,
			b.getDimensionPixelSize(R.dimen.bar_pointer_radius));
	mBarPointerHaloRadius = a.getDimensionPixelSize(
			R.styleable.ColorBars_bar_pointer_halo_radius,
			b.getDimensionPixelSize(R.dimen.bar_pointer_halo_radius));
	mOrientation = a.getBoolean(
			R.styleable.ColorBars_bar_orientation_horizontal, ORIENTATION_DEFAULT);

	a.recycle();

	mBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mBarPaint.setShader(shader);

	mBarPointerPosition = mBarLength + mBarPointerHaloRadius;

	mBarPointerHaloPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mBarPointerHaloPaint.setColor(Color.BLACK);
	mBarPointerHaloPaint.setAlpha(0x50);

	mBarPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mBarPointerPaint.setColor(0xff81ff00);

	mPosToSatFactor = 1 / ((float) mBarLength);
	mSatToPosFactor = ((float) mBarLength) / 1;
}
 
Example 5
Project: mvparms   File: AutoTabLayout.java   View Source Code Vote up 5 votes
private int loadTextSizeFromTextAppearance(int textAppearanceResId)
{
    TypedArray a = getContext().obtainStyledAttributes(textAppearanceResId,
            R.styleable.TextAppearance);

    try
    {
        if (!DimenUtils.isPxVal(a.peekValue(R.styleable.TextAppearance_android_textSize)))
            return NO_VALID;
        return a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, NO_VALID);
    } finally
    {
        a.recycle();
    }
}
 
Example 6
Project: boohee_v5.6   File: OverlayView.java   View Source Code Vote up 5 votes
private void initCropFrameStyle(@NonNull TypedArray a) {
    int cropFrameStrokeSize = a.getDimensionPixelSize(R.styleable
            .ucrop_UCropView_ucrop_frame_stroke_size, getResources().getDimensionPixelSize(R
            .dimen.ucrop_default_crop_frame_stoke_width));
    int cropFrameColor = a.getColor(R.styleable.ucrop_UCropView_ucrop_frame_color,
            getResources().getColor(R.color.ucrop_color_default_crop_frame));
    this.mCropFramePaint.setStrokeWidth((float) cropFrameStrokeSize);
    this.mCropFramePaint.setColor(cropFrameColor);
    this.mCropFramePaint.setStyle(Style.STROKE);
}
 
Example 7
Project: DarkCalculator   File: AutofitHelper.java   View Source Code Vote up 5 votes
/**
 * Creates a new instance of {@code AutofitHelper} that wraps a {@link TextView} and enables
 * automatically sizing the text to fit.
 */
public static AutofitHelper create(TextView view, AttributeSet attrs, int defStyle) {
    AutofitHelper helper = new AutofitHelper(view);
    boolean sizeToFit = true;
    if (attrs != null) {
        Context context = view.getContext();
        int minTextSize = (int) helper.getMinTextSize();
        float precision = helper.getPrecision();

        TypedArray ta = context.obtainStyledAttributes(
                attrs,
                R.styleable.AutofitTextView,
                defStyle,
                0);
        sizeToFit = ta.getBoolean(R.styleable.AutofitTextView_sizeToFit, sizeToFit);
        minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitTextView_minTextSize,
                minTextSize);
        precision = ta.getFloat(R.styleable.AutofitTextView_precision, precision);
        ta.recycle();

        helper.setMinTextSize(TypedValue.COMPLEX_UNIT_PX, minTextSize)
                .setPrecision(precision);
    }
    helper.setEnabled(sizeToFit);

    return helper;
}
 
Example 8
Project: aarLibrary   File: CommonTabLayout.java   View Source Code Vote up 5 votes
public CommonTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
    setClipChildren(false);
    setClipToPadding(false);

    this.mContext = context;
    mTabsContainer = new LinearLayout(context);
    addView(mTabsContainer);

    obtainAttributes(context, attrs);

    //get layout_height
    String height = attrs.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

    //create ViewPager
    if (height.equals(ViewGroup.LayoutParams.MATCH_PARENT + "")) {
    } else if (height.equals(ViewGroup.LayoutParams.WRAP_CONTENT + "")) {
    } else {
        int[] systemAttrs = {android.R.attr.layout_height};
        TypedArray a = context.obtainStyledAttributes(attrs, systemAttrs);
        mHeight = a.getDimensionPixelSize(0, ViewGroup.LayoutParams.WRAP_CONTENT);
        a.recycle();
    }

    mValueAnimator = ValueAnimator.ofObject(new PointEvaluator(), mLastP, mCurrentP);
    mValueAnimator.addUpdateListener(this);
}
 
Example 9
Project: YCUtils   File: MaterialRippleLayout.java   View Source Code Vote up 5 votes
public MaterialRippleLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, longClickListener);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialRippleLayout);
    rippleColor = a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleColor, DEFAULT_COLOR);
    rippleDiameter = a.getDimensionPixelSize(
        R.styleable.MaterialRippleLayout_mrl_rippleDimension,
        (int) dpToPx(getResources(), DEFAULT_DIAMETER_DP)
    );
    rippleOverlay = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleOverlay, DEFAULT_RIPPLE_OVERLAY);
    rippleHover = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleHover, DEFAULT_HOVER);
    rippleDuration = a.getInt(R.styleable.MaterialRippleLayout_mrl_rippleDuration, DEFAULT_DURATION);
    rippleAlpha = (int) (255 * a.getFloat(R.styleable.MaterialRippleLayout_mrl_rippleAlpha, DEFAULT_ALPHA));
    rippleDelayClick = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleDelayClick, DEFAULT_DELAY_CLICK);
    rippleFadeDuration = a.getInteger(R.styleable.MaterialRippleLayout_mrl_rippleFadeDuration, DEFAULT_FADE_DURATION);
    rippleBackground = new ColorDrawable(a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleBackground, DEFAULT_BACKGROUND));
    ripplePersistent = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_ripplePersistent, DEFAULT_PERSISTENT);
    rippleInAdapter = a.getBoolean(R.styleable.MaterialRippleLayout_mrl_rippleInAdapter, DEFAULT_SEARCH_ADAPTER);
    rippleRoundedCorners = a.getDimensionPixelSize(R.styleable.MaterialRippleLayout_mrl_rippleRoundedCorners, DEFAULT_ROUNDED_CORNERS);

    a.recycle();

    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);

    enableClipPathSupportIfNecessary();
}
 
Example 10
Project: qmui   File: QMUIRadiusImageView.java   View Source Code Vote up 5 votes
public QMUIRadiusImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mBorderPaint = new Paint();
    mBorderPaint.setAntiAlias(true);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mMatrix = new Matrix();

    setScaleType(ScaleType.CENTER_CROP);

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.QMUIRadiusImageView, defStyleAttr, 0);

    mBorderWidth = array.getDimensionPixelSize(R.styleable.QMUIRadiusImageView_qmui_border_width, 0);
    mBorderColor = array.getColor(R.styleable.QMUIRadiusImageView_qmui_border_color, DEFAULT_BORDER_COLOR);
    mSelectedBorderWidth = array.getDimensionPixelSize(
            R.styleable.QMUIRadiusImageView_qmui_selected_border_width, mBorderWidth);
    mSelectedBorderColor = array.getColor(R.styleable.QMUIRadiusImageView_qmui_selected_border_color, mBorderColor);
    mSelectedMaskColor = array.getColor(R.styleable.QMUIRadiusImageView_qmui_selected_mask_color, Color.TRANSPARENT);
    if (mSelectedMaskColor != Color.TRANSPARENT) {
        mSelectedColorFilter = new PorterDuffColorFilter(mSelectedMaskColor, PorterDuff.Mode.DARKEN);
    }

    mIsTouchSelectModeEnabled = array.getBoolean(R.styleable.QMUIRadiusImageView_qmui_is_touch_select_mode_enabled, true);
    mIsCircle = array.getBoolean(R.styleable.QMUIRadiusImageView_qmui_is_circle, false);
    if (!mIsCircle) {
        mIsOval = array.getBoolean(R.styleable.QMUIRadiusImageView_qmui_is_oval, false);
    }
    if (!mIsOval) {
        mCornerRadius = array.getDimensionPixelSize(R.styleable.QMUIRadiusImageView_qmui_corner_radius, 0);
    }
    array.recycle();
}
 
Example 11
Project: animated-ratingbar   File: AnimatedRatingBar.java   View Source Code Vote up 5 votes
private void setAttrs(Context context, AttributeSet attrs) {
    if (attrs == null) {
        return;
    }

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.AnimatedRatingBar);
    int progressImageResource = ta.getResourceId(R.styleable.AnimatedRatingBar_progressImage, R.id.progress_image);
    int secondaryProgressImageResource = ta.getResourceId(R.styleable.AnimatedRatingBar_secondaryProgressImage, R.id.secondary_progress_image);

    if (progressImageResource != 0) {
        progressImage = getResources().getDrawable(progressImageResource);
    }

    if (secondaryProgressImageResource != 0) {
        secondaryProgressImage = getResources().getDrawable(secondaryProgressImageResource);
    }


    numStars = ta.getInt(R.styleable.AnimatedRatingBar_numStars, 5);
    max = ta.getInt(R.styleable.AnimatedRatingBar_max, 5);
    rating = ta.getFloat(R.styleable.AnimatedRatingBar_rating, 2.5f);
    gapSize = ta.getDimensionPixelSize(R.styleable.AnimatedRatingBar_gapSize, 20);
    starSize = ta.getDimensionPixelSize(R.styleable.AnimatedRatingBar_starSize, 30);
    seekable = ta.getBoolean(R.styleable.AnimatedRatingBar_seekable, false);

    ta.recycle();
}
 
Example 12
Project: FLFloatingButton   File: ArcMenu.java   View Source Code Vote up 5 votes
private void applyAttrs(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ArcLayout, 0, 0);

        float fromDegrees = a.getFloat(R.styleable.ArcLayout_fromDegrees, ArcLayout.DEFAULT_FROM_DEGREES);
        float toDegrees = a.getFloat(R.styleable.ArcLayout_toDegrees, ArcLayout.DEFAULT_TO_DEGREES);
        mArcLayout.setArc(fromDegrees, toDegrees);

        int defaultChildSize = mArcLayout.getChildSize();
        int newChildSize = a.getDimensionPixelSize(R.styleable.ArcLayout_childSize, defaultChildSize);
        mArcLayout.setChildSize(newChildSize);

        a.recycle();
    }
}
 
Example 13
Project: ViewPagerHelper   File: TransIndicator.java   View Source Code Vote up 5 votes
public TransIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TransIndicator);
    mLeftMargin =  ta.getDimensionPixelSize(R.styleable.TransIndicator_trans_leftmargin,20);
    mTransWidht =  ta.getDimensionPixelSize(R.styleable.TransIndicator_trans_width,mTransWidht);
    mTransHeight =  ta.getDimensionPixelSize(R.styleable.TransIndicator_trans_height,mTransHeight);
    mDefaultcolor = ta.getColor(R.styleable.TransIndicator_trans_defaultcolor,
            mDefaultcolor);
    mMovecolor = ta.getColor(R.styleable.TransIndicator_trans_movecolor,
           mMovecolor);
    mDismissOpen = ta.getBoolean(R.styleable.TransIndicator_trans_dismiss_open,false);
    mTransType = ta.getInteger(R.styleable.TransIndicator_trans_type,TRANS_CIRCLE);
    mRoundRadius = ta.getDimensionPixelSize(R.styleable.TransIndicator_trans_round_radius,7);
    ta.recycle();


    setGravity(Gravity.CENTER);
    mPath = new Path();
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(mMovecolor);
    setClipChildren(false);
    setClipToPadding(false);

}
 
Example 14
Project: sealtalk-android-master   File: CircleImageView.java   View Source Code Vote up 5 votes
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);

    mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
    mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
    mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
    mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);

    a.recycle();

    init();
}
 
Example 15
Project: CircleRangeView   File: CircleRangeView.java   View Source Code Vote up 4 votes
public CircleRangeView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleRangeView);

    rangeColorArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeColorArray);
    rangeValueArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeValueArray);
    rangeTextArray = typedArray.getTextArray(R.styleable.CircleRangeView_rangeTextArray);

    borderColor = typedArray.getColor(R.styleable.CircleRangeView_borderColor, borderColor);
    cursorColor = typedArray.getColor(R.styleable.CircleRangeView_cursorColor, cursorColor);
    extraTextColor = typedArray.getColor(R.styleable.CircleRangeView_extraTextColor, extraTextColor);

    rangeTextSize = typedArray.getDimensionPixelSize(R.styleable.CircleRangeView_rangeTextSize, rangeTextSize);
    extraTextSize = typedArray.getDimensionPixelSize(R.styleable.CircleRangeView_extraTextSize, extraTextSize);

    typedArray.recycle();

    if (rangeColorArray == null || rangeValueArray == null || rangeTextArray == null) {
        throw new IllegalArgumentException("CircleRangeView : rangeColorArray、 rangeValueArray、rangeTextArray  must be not null ");
    }
    if (rangeColorArray.length != rangeValueArray.length
            || rangeColorArray.length != rangeTextArray.length
            || rangeValueArray.length != rangeTextArray.length) {
        throw new IllegalArgumentException("arrays must be equal length");
    }

    this.mSection = rangeColorArray.length;

    mSparkleWidth = dp2px(15);
    mCalibrationWidth = dp2px(10);

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStrokeCap(Paint.Cap.ROUND);

    mRectFProgressArc = new RectF();
    mRectFCalibrationFArc = new RectF();
    mRectText = new Rect();

    mBackgroundColor = android.R.color.transparent;
}
 
Example 16
Project: ChatExchange-old   File: FloatingActionMenu.java   View Source Code Vote up 4 votes
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mOpenRotationLeft = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_left, (int)OPENED_PLUS_ROTATION_LEFT);
    mOpenRotationRight = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_right, (int)OPENED_PLUS_ROTATION_RIGHT);
    mAnimationDuration = attr.getInt((int)getAnimDuration(R.styleable.FloatingActionMenu_menu_fab_animation_duration, context), (int)getAnimDuration(ANIMATION_DURATION, context));
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    try
    {
        mIcon = VectorDrawableCompat.create(attr.getResources(), attr.getResourceId(R.styleable.FloatingActionMenu_menu_icon, R.drawable.fab_add), null);
    } catch (Resources.NotFoundException e) {
        e.printStackTrace();
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example 17
Project: Notepad2   File: SmoothCheckBox.java   View Source Code Vote up 4 votes
private void init(AttributeSet attrs) {

        TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.SmoothCheckBox);
        int tickColor = ta.getColor(R.styleable.SmoothCheckBox_color_tick, COLOR_TICK);
        mAnimDuration = ta.getInt(R.styleable.SmoothCheckBox_duration, DEF_ANIM_DURATION);
        mFloorColor = ta.getColor(R.styleable.SmoothCheckBox_color_unchecked_stroke, COLOR_FLOOR_UNCHECKED);
        mCheckedColor = ta.getColor(R.styleable.SmoothCheckBox_color_checked, COLOR_CHECKED);
        mUnCheckedColor = ta.getColor(R.styleable.SmoothCheckBox_color_unchecked, COLOR_UNCHECKED);
        mStrokeWidth = ta.getDimensionPixelSize(R.styleable.SmoothCheckBox_stroke_width, CompatUtils.dp2px(getContext(), 0));
        ta.recycle();

        mFloorUnCheckedColor = mFloorColor;
        mTickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mTickPaint.setStyle(Paint.Style.STROKE);
        mTickPaint.setStrokeCap(Paint.Cap.ROUND);
        mTickPaint.setColor(tickColor);

        mFloorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mFloorPaint.setStyle(Paint.Style.FILL);
        mFloorPaint.setColor(mFloorColor);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(mCheckedColor);

        mTickPath = new Path();
        mCenterPoint = new Point();
        mTickPoints = new Point[3];
        mTickPoints[0] = new Point();
        mTickPoints[1] = new Point();
        mTickPoints[2] = new Point();

        setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                toggle();
                mTickDrawing = false;
                mDrewDistance = 0;
                if (isChecked()) {
                    startCheckedAnimation();
                } else {
                    startUnCheckedAnimation();
                }
            }
        });
    }
 
Example 18
Project: CSipSimple   File: IcsProgressBar.java   View Source Code Vote up 4 votes
/**
 * @hide
 */
public IcsProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) {
    super(context, attrs, defStyle);
    mUiThreadId = Thread.currentThread().getId();
    initProgressBar();

    TypedArray a =
        context.obtainStyledAttributes(attrs, /*R.styleable.*/ProgressBar, defStyle, styleRes);

    mNoInvalidate = true;

    Drawable drawable = a.getDrawable(/*R.styleable.*/ProgressBar_progressDrawable);
    if (drawable != null) {
        drawable = tileify(drawable, false);
        // Calling this method can set mMaxHeight, make sure the corresponding
        // XML attribute for mMaxHeight is read after calling this method
        setProgressDrawable(drawable);
    }


    mDuration = a.getInt(/*R.styleable.*/ProgressBar_indeterminateDuration, mDuration);

    mMinWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minWidth, mMinWidth);
    mMaxWidth = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxWidth, mMaxWidth);
    mMinHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_minHeight, mMinHeight);
    mMaxHeight = a.getDimensionPixelSize(/*R.styleable.*/ProgressBar_maxHeight, mMaxHeight);

    mBehavior = a.getInt(/*R.styleable.*/ProgressBar_indeterminateBehavior, mBehavior);

    final int resID = a.getResourceId(
            /*com.android.internal.R.styleable.*/ProgressBar_interpolator,
            android.R.anim.linear_interpolator); // default to linear interpolator
    if (resID > 0) {
        setInterpolator(context, resID);
    }

    setMax(a.getInt(/*R.styleable.*/ProgressBar_max, mMax));

    setProgress(a.getInt(/*R.styleable.*/ProgressBar_progress, mProgress));

    setSecondaryProgress(
            a.getInt(/*R.styleable.*/ProgressBar_secondaryProgress, mSecondaryProgress));

    drawable = a.getDrawable(/*R.styleable.*/ProgressBar_indeterminateDrawable);
    if (drawable != null) {
        drawable = tileifyIndeterminate(drawable);
        setIndeterminateDrawable(drawable);
    }

    mOnlyIndeterminate = a.getBoolean(
            /*R.styleable.*/ProgressBar_indeterminateOnly, mOnlyIndeterminate);

    mNoInvalidate = false;

    setIndeterminate(mOnlyIndeterminate || a.getBoolean(
            /*R.styleable.*/ProgressBar_indeterminate, mIndeterminate));

    mAnimationResolution = a.getInteger(/*R.styleable.*/ProgressBar_animationResolution,
            ANIMATION_RESOLUTION);

    a.recycle();

    mAccessibilityManager = (AccessibilityManager)context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
Example 19
Project: Orin   File: Util.java   View Source Code Vote up 4 votes
public static int resolveDimensionPixelSize(@NonNull Context context, @AttrRes int dimenAttr) {
    TypedArray a = context.obtainStyledAttributes(new int[]{dimenAttr});
    int dimensionPixelSize = a.getDimensionPixelSize(0, 0);
    a.recycle();
    return dimensionPixelSize;
}
 
Example 20
Project: NeiHanDuanZiTV   File: BGABanner.java   View Source Code Vote up 4 votes
private void initCustomAttr(int attr, TypedArray typedArray) {
    if (attr == R.styleable.BGABanner_banner_pointDrawable) {
        mPointDrawableResId = typedArray.getResourceId(attr, R.drawable.bga_banner_selector_point_solid);
    } else if (attr == R.styleable.BGABanner_banner_pointContainerBackground) {
        mPointContainerBackgroundDrawable = typedArray.getDrawable(attr);
    } else if (attr == R.styleable.BGABanner_banner_pointLeftRightMargin) {
        mPointLeftRightMargin = typedArray.getDimensionPixelSize(attr, mPointLeftRightMargin);
    } else if (attr == R.styleable.BGABanner_banner_pointContainerLeftRightPadding) {
        mPointContainerLeftRightPadding = typedArray.getDimensionPixelSize(attr, mPointContainerLeftRightPadding);
    } else if (attr == R.styleable.BGABanner_banner_pointTopBottomMargin) {
        mPointTopBottomMargin = typedArray.getDimensionPixelSize(attr, mPointTopBottomMargin);
    } else if (attr == R.styleable.BGABanner_banner_indicatorGravity) {
        mPointGravity = typedArray.getInt(attr, mPointGravity);
    } else if (attr == R.styleable.BGABanner_banner_pointAutoPlayAble) {
        mAutoPlayAble = typedArray.getBoolean(attr, mAutoPlayAble);
    } else if (attr == R.styleable.BGABanner_banner_pointAutoPlayInterval) {
        mAutoPlayInterval = typedArray.getInteger(attr, mAutoPlayInterval);
    } else if (attr == R.styleable.BGABanner_banner_pageChangeDuration) {
        mPageChangeDuration = typedArray.getInteger(attr, mPageChangeDuration);
    } else if (attr == R.styleable.BGABanner_banner_transitionEffect) {
        int ordinal = typedArray.getInt(attr, TransitionEffect.Accordion.ordinal());
        mTransitionEffect = TransitionEffect.values()[ordinal];
    } else if (attr == R.styleable.BGABanner_banner_tipTextColor) {
        mTipTextColor = typedArray.getColor(attr, mTipTextColor);
    } else if (attr == R.styleable.BGABanner_banner_tipTextSize) {
        mTipTextSize = typedArray.getDimensionPixelSize(attr, mTipTextSize);
    } else if (attr == R.styleable.BGABanner_banner_placeholderDrawable) {
        mPlaceholderDrawableResId = typedArray.getResourceId(attr, mPlaceholderDrawableResId);
    } else if (attr == R.styleable.BGABanner_banner_isNumberIndicator) {
        mIsNumberIndicator = typedArray.getBoolean(attr, mIsNumberIndicator);
    } else if (attr == R.styleable.BGABanner_banner_numberIndicatorTextColor) {
        mNumberIndicatorTextColor = typedArray.getColor(attr, mNumberIndicatorTextColor);
    } else if (attr == R.styleable.BGABanner_banner_numberIndicatorTextSize) {
        mNumberIndicatorTextSize = typedArray.getDimensionPixelSize(attr, mNumberIndicatorTextSize);
    } else if (attr == R.styleable.BGABanner_banner_numberIndicatorBackground) {
        mNumberIndicatorBackground = typedArray.getDrawable(attr);
    } else if (attr == R.styleable.BGABanner_banner_isNeedShowIndicatorOnOnlyOnePage) {
        mIsNeedShowIndicatorOnOnlyOnePage = typedArray.getBoolean(attr, mIsNeedShowIndicatorOnOnlyOnePage);
    } else if (attr == R.styleable.BGABanner_banner_contentBottomMargin) {
        mContentBottomMargin = typedArray.getDimensionPixelSize(attr, mContentBottomMargin);
    } else if (attr == R.styleable.BGABanner_android_scaleType) {
        final int index = typedArray.getInt(attr, -1);
        if (index >= 0 && index < sScaleTypeArray.length) {
            mPlaceholderScaleType = sScaleTypeArray[index];
        }
    }
}