List of usage examples for android.content.res TypedArray getFloat
public float getFloat(@StyleableRes int index, float defValue)
From source file:com.hippo.widget.ProgressView.java
private void init(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressView); int color = a.getColor(R.styleable.ProgressView_color, Color.BLACK); mPaint.setColor(color);//from w w w.ja v a 2s .c o m mPaint.setStrokeCap(Paint.Cap.SQUARE); mPaint.setStrokeJoin(Paint.Join.MITER); mPaint.setStyle(Paint.Style.STROKE); mIndeterminate = a.getBoolean(R.styleable.ProgressView_indeterminate, true); setProgress(a.getFloat(R.styleable.ProgressView_progress, 0f)); a.recycle(); setupAnimators(); }
From source file:com.tompee.funtablayout.FunTabLayout.java
private void getAttributes(Context context, AttributeSet attrs, int defStyle) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FunTabLayout, defStyle, 0); mScrollEanbled = a.getBoolean(R.styleable.FunTabLayout_scrollEnabled, true); mTabVisibleCount = a.getInteger(R.styleable.FunTabLayout_tabVisibleCount, 0); mPositionThreshold = a.getFloat(R.styleable.FunTabLayout_positionThreshold, DEFAULT_POSITION_THRESHOLD); a.recycle();//from ww w . j a v a 2s. c o m }
From source file:io.plaidapp.ui.widget.ElasticDragDismissFrameLayout.java
private void init(AttributeSet attrs) { final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ElasticDragDismissFrameLayout, 0, 0);/*from w w w. j ava 2 s.co m*/ if (a.hasValue(R.styleable.ElasticDragDismissFrameLayout_dragDismissDistance)) { dragDismissDistance = a .getDimensionPixelSize(R.styleable.ElasticDragDismissFrameLayout_dragDismissDistance, 0); } else if (a.hasValue(R.styleable.ElasticDragDismissFrameLayout_dragDismissFraction)) { dragDismissFraction = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragDismissFraction, dragDismissFraction); } if (a.hasValue(R.styleable.ElasticDragDismissFrameLayout_dragDismissScale)) { dragDismissScale = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragDismissScale, dragDismissScale); shouldScale = dragDismissScale != 1f; } if (a.hasValue(R.styleable.ElasticDragDismissFrameLayout_dragElasticity)) { dragElacticity = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragElasticity, dragElacticity); } a.recycle(); }
From source file:com.github.ppamorim.dragger.DraggerView.java
private void initializeAttributes(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.dragger_layout); this.dragLimit = attributes.getFloat(R.styleable.dragger_layout_drag_limit, DEFAULT_DRAG_LIMIT); this.dragPosition = DraggerPosition.getDragPosition( attributes.getInt(R.styleable.dragger_layout_drag_position, DEFAULT_DRAG_POSITION)); this.tension = attributes.getInteger(R.styleable.dragger_layout_tension, DEFAULT_TENSION); this.friction = attributes.getInteger(R.styleable.dragger_layout_friction, DEFAULT_FRICTION); this.attributes = attributes; }
From source file:am.widget.scalerecyclerview.ScaleRecyclerView.java
private void initView(Context context, @Nullable AttributeSet attrs) { final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.ScaleRecyclerView); mScaleEnable = custom.getBoolean(R.styleable.ScaleRecyclerView_srvScaleEnable, false); mScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvScale, 1); mMinScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvMinScale, 0.000000001f); mMaxScale = custom.getFloat(R.styleable.ScaleRecyclerView_srvMaxScale, 6); custom.recycle();/*from ww w.j av a2 s .co m*/ mGestureDetector = new GestureDetectorCompat(context, new DoubleTapListener()); mScaleGestureDetector = new ScaleGestureDetector(context, new ScaleListener()); }
From source file:org.gearvrf.keyboard.model.SphereFlag.java
private void initSphere(TypedArray sphere) { Resources res = gvrContext.getContext().getResources(); mCountryName = res.getString(sphere.getResourceId(0, -1)); mTexture = sphere.getResourceId(1, -1); mQuestion = res.getString(sphere.getResourceId(2, -1)); mAnswer = res.getString(sphere.getResourceId(3, -1)); mResultTexture = R.drawable.check;/*from ww w. ja va 2 s . c o m*/ float posX = Util.applyRatioAt(sphere.getFloat(4, -1)); float posY = Util.applyRatioAt(sphere.getFloat(5, -1)); float posZ = Util.applyRatioAt(sphere.getFloat(6, -1)); positionVector = new Vector3D(posX, posY, posZ); }
From source file:lemonlabs.android.expandablebuttonmenu.ExpandableButtonMenu.java
/** * Parses custom XML attributes//w w w . j a va 2 s. c o m * * @param attrs */ private void parseAttributes(AttributeSet attrs) { if (attrs != null) { TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ExpandableMenuOverlay, 0, 0); try { // button metrics mainButtonSize = a.getFloat(R.styleable.ExpandableMenuOverlay_mainButtonSize, DEFAULT_MAIN_BUTTON_SIZE); otherButtonSize = a.getFloat(R.styleable.ExpandableMenuOverlay_otherButtonSize, DEFAULT_OTHER_BUTTON_SIZE); bottomPadding = a.getFloat(R.styleable.ExpandableMenuOverlay_bottomPad, DEFAULT_BOTTOM_PADDING); buttonDistanceY = a.getFloat(R.styleable.ExpandableMenuOverlay_distanceY, DEFAULT_BUTTON_DISTANCE_Y); buttonDistanceX = a.getFloat(R.styleable.ExpandableMenuOverlay_distanceX, DEFAULT_BUTTON_DISTANCE_X); // button resources mCloseBtn.setBackgroundResource( a.getResourceId(R.styleable.ExpandableMenuOverlay_closeButtonSrc, 0)); mLeftBtn.setBackgroundResource(a.getResourceId(R.styleable.ExpandableMenuOverlay_leftButtonSrc, 0)); mRightBtn.setBackgroundResource( a.getResourceId(R.styleable.ExpandableMenuOverlay_rightButtonSrc, 0)); mMidBtn.setBackgroundResource(a.getResourceId(R.styleable.ExpandableMenuOverlay_midButtonSrc, 0)); // button text mLeftText .setText(a.getResourceId(R.styleable.ExpandableMenuOverlay_leftButtonText, R.string.empty)); mRightText.setText( a.getResourceId(R.styleable.ExpandableMenuOverlay_rightButtonText, R.string.empty)); mMidText.setText(a.getResourceId(R.styleable.ExpandableMenuOverlay_midButtonText, R.string.empty)); } finally { a.recycle(); } } }
From source file:com.vinaysshenoy.okulus.OkulusImageView.java
/** * @param context/*from www . j a v a2 s .co m*/ * @param attrs */ @TargetApi(Build.VERSION_CODES.KITKAT) private void init(Context context, AttributeSet attrs) { mViewRect = new Rect(); mCornerRadius = dpToPx(DEFAULT_CORNER_RADIUS); float borderWidthInDips = DEFAULT_BORDER_WIDTH; mBorderColor = DEFAULT_BORDER_COLOR; mFullCircle = DEFAULT_FULL_CIRCLE; float shadowWidthInDips = DEFAULT_SHADOW_WIDTH; mShadowColor = DEFAULT_SHADOW_COLOR; mShadowRadius = DEFAULT_SHADOW_RADIUS; mTouchSelectorColor = DEFAULT_TOUCH_SELECTOR_COLOR; mTouchSelectorEnabled = DEFAULT_TOUCH_SELECTOR_ENABLED; if (attrs != null) { TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.OkulusImageView); mCornerRadius = styledAttrs.getDimension(R.styleable.OkulusImageView_cornerRadius, mCornerRadius); mBorderColor = styledAttrs.getColor(R.styleable.OkulusImageView_borderColor, mBorderColor); mFullCircle = styledAttrs.getBoolean(R.styleable.OkulusImageView_fullCircle, mFullCircle); mShadowColor = styledAttrs.getColor(R.styleable.OkulusImageView_shadowColor, mShadowColor); mShadowRadius = styledAttrs.getFloat(R.styleable.OkulusImageView_shadowRadius, mShadowRadius); mTouchSelectorColor = styledAttrs.getColor(R.styleable.OkulusImageView_touchSelectorColor, mTouchSelectorColor); mTouchSelectorEnabled = styledAttrs.getBoolean(R.styleable.OkulusImageView_touchSelectorEnabled, mTouchSelectorEnabled); float dimension = styledAttrs.getDimension(R.styleable.OkulusImageView_borderWidth, borderWidthInDips); borderWidthInDips = pxToDp(dimension); dimension = styledAttrs.getDimension(R.styleable.OkulusImageView_shadowWidth, shadowWidthInDips); shadowWidthInDips = pxToDp(dimension); styledAttrs.recycle(); } clampBorderAndShadowWidths(borderWidthInDips, shadowWidthInDips); mBorderWidth = dpToPx(borderWidthInDips); mShadowWidth = dpToPx(shadowWidthInDips); if (mShadowWidth > 0f) { if (Build.VERSION.SDK_INT >= 14) { /* We need to set layer type for shadows to work * on ICS and above */ setLayerType(View.LAYER_TYPE_SOFTWARE, null); } } setOkulusDrawable(null); }
From source file:dg.shenm233.drag2expandview.Drag2ExpandView.java
public Drag2ExpandView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); if (attrs != null) { TypedArray o = context.obtainStyledAttributes(attrs, OTHER_ATTRS); if (o != null) { int gravity = o.getInt(0, Gravity.NO_GRAVITY); setGravity(gravity);//from www .j a va 2 s . c o m o.recycle(); } TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Drag2ExpandView); if (a != null) { mHeaderHeight = a.getDimensionPixelSize(R.styleable.Drag2ExpandView_sHeaderHeight, -1); mScrollableViewResId = a.getResourceId(R.styleable.Drag2ExpandView_sScrollableView, -1); mDragViewResId = a.getResourceId(R.styleable.Drag2ExpandView_sViewToDrag, -1); mAnchorOffset = a.getFloat(R.styleable.Drag2ExpandView_sAnchorOffset, 1.0f); a.recycle(); } } mViewDragHelper = ViewDragHelper.create(this, 1.0f, mViewDragCallback = new ViewDragCallback()); mScrollableViewHelper = new ScrollableViewHelper(); }
From source file:com.github.rubensousa.stackview.StackView.java
public StackView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mViews = new ArrayList<>(); mRandom = new Random(); mHardwareAccelerationEnabled = true; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StackView, 0, 0); mSize = a.getInteger(R.styleable.StackView_stackview_size, 4); mHorizontalSpacing = a.getDimension(R.styleable.StackView_stackview_horizontalSpacing, 0f); mVerticalSpacing = a.getDimension(R.styleable.StackView_stackview_verticalSpacing, VERTICAL_SPACING); mElevationSpacing = a.getDimension(R.styleable.StackView_stackview_elevationSpacing, ELEVATION_SPACING); mItemMaxRotation = a.getInteger(R.styleable.StackView_stackview_rotationRandomMagnitude, 0); mScaleXFactor = a.getFloat(R.styleable.StackView_stackview_horizontalScalingFactor, SCALE_X_FACTOR); if (mScaleXFactor < 0 || mScaleXFactor > 1) { throw new IllegalArgumentException( "horizontalScalingFactor must be greater than 0" + "and less than 1"); }// w w w.j a v a 2 s . c om mCyclicLooping = a.getBoolean(R.styleable.StackView_stackview_cyclicLooping, false); mLayout = a.getResourceId(R.styleable.StackView_stackview_adapterLayout, 0); mAnimator = new StackDefaultAnimator(); mAnimator.setStackView(this); mAnimator.setStackAnimationListener(this); a.recycle(); setClipToPadding(false); setClipChildren(false); if (isInEditMode()) { addViews(); } }