List of usage examples for android.content.res TypedArray getFloat
public float getFloat(@StyleableRes int index, float defValue)
From source file:com.evilduck.animtest.DraggedPanelLayout.java
public void initAttrs(Context context, AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DraggedPanelLayout, 0, 0); try {//ww w .ja v a2 s . c o m parallaxFactor = a.getFloat(R.styleable.DraggedPanelLayout_parallax_factor, PARALLAX_FACTOR); if (parallaxFactor < 0.1 || parallaxFactor > 0.9) { parallaxFactor = PARALLAX_FACTOR; } int defaultHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); bottomPanelPeekHeight = a.getDimensionPixelSize(R.styleable.DraggedPanelLayout_bottom_panel_height, defaultHeight); int shadowDrawableId = a.getResourceId(R.styleable.DraggedPanelLayout_shadow_drawable, -1); if (shadowDrawableId != -1) { shadowDrawable = getResources().getDrawable(shadowDrawableId); willDrawShadow = true; setWillNotDraw(!willDrawShadow); } } finally { a.recycle(); } final ViewConfiguration configuration = ViewConfiguration.get(getContext()); touchSlop = configuration.getScaledTouchSlop(); }
From source file:com.arbo.gaogao.widget.MyParallaxScrimageView.java
public MyParallaxScrimageView(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView); if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) { scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor); }//ww w.j ava 2s . co m if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) { scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) { maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) { parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor); } a.recycle(); scrimPaint = new Paint(); scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha)); }
From source file:com.arbo.gaogao.widget.ParallaxScrimageView.java
public ParallaxScrimageView(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView); if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) { scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor); }/* ww w .j av a 2s .com*/ if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) { scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) { maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) { parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor); } a.recycle(); scrimPaint = new Paint(); scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha)); }
From source file:com.github.pedrovgs.DraggablePanel.java
/** * Initialize the xml configuration based on styleable attributes * * @param attrs to analyze.//from w ww . ja v a 2s .co m */ private final void initializeAttrs(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.draggable_panel); this.topFragmentHeight = attributes.getDimension(R.styleable.draggable_panel_top_fragment_height, DEFAULT_TOP_FRAGMENT_HEIGHT); this.xScaleFactor = attributes.getFloat(R.styleable.draggable_panel_x_scale_factor, DEFAULT_SCALE_FACTOR); this.yScaleFactor = attributes.getFloat(R.styleable.draggable_panel_y_scale_factor, DEFAULT_SCALE_FACTOR); this.topFragmentMarginRight = attributes.getDimension(R.styleable.draggable_panel_top_fragment_margin_right, DEFAULT_TOP_FRAGMENT_MARGIN); this.topFragmentMarginBottom = attributes .getDimension(R.styleable.draggable_panel_top_fragment_margin_bottom, DEFAULT_TOP_FRAGMENT_MARGIN); this.enableHorizontalAlphaEffect = attributes.getBoolean( R.styleable.draggable_panel_enable_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT); attributes.recycle(); }
From source file:com.pedrovgs.draggablepanel.DraggablePanel.java
/** * Initialize the xml configuration based on styleable attributes * * @param attrs to analyze./* w ww . ja v a 2 s. c om*/ */ private void initializeAttrs(AttributeSet attrs) { TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.draggable_panel); this.topFragmentHeight = attributes.getDimensionPixelSize(R.styleable.draggable_panel_top_fragment_height, DEFAULT_TOP_FRAGMENT_HEIGHT); this.xScaleFactor = attributes.getFloat(R.styleable.draggable_panel_x_scale_factor, DEFAULT_SCALE_FACTOR); this.yScaleFactor = attributes.getFloat(R.styleable.draggable_panel_y_scale_factor, DEFAULT_SCALE_FACTOR); this.topFragmentMarginRight = attributes.getDimensionPixelSize( R.styleable.draggable_panel_top_fragment_margin_right, DEFAULT_TOP_FRAGMENT_MARGIN); this.topFragmentMarginBottom = attributes.getDimensionPixelSize( R.styleable.draggable_panel_top_fragment_margin_bottom, DEFAULT_TOP_FRAGMENT_MARGIN); this.enableHorizontalAlphaEffect = attributes.getBoolean( R.styleable.draggable_panel_enable_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT); attributes.recycle(); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticCheckButton.java
private void setTypeArray(TypedArray typedArray) { GradientDrawable bgShape = (GradientDrawable) view.getBackground(); round = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_round, round); bgShape.setCornerRadius(round);/* w w w.j a v a 2 s. c o m*/ color = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_backgroundColor, color); bgShape.setColor(color); scale = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_scale, scale); duration = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_duration, duration); labelText = typedArray.getString(R.styleable.ElasticCheckButton_checkbutton_labelText); view.setText(labelText); labelColor = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelColor, labelColor); view.setTextColor(labelColor); labelSize = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelSize, labelSize); view.setTextSize(labelSize); labelStyle = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelStyle, labelStyle); if (labelStyle == 0) view.setTypeface(null, Typeface.NORMAL); else if (labelStyle == 1) view.setTypeface(null, Typeface.BOLD); else if (labelStyle == 2) view.setTypeface(null, Typeface.ITALIC); alpha = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_alpha, alpha); checked = typedArray.getBoolean(R.styleable.ElasticCheckButton_checkbutton_ischecked, checked); if (checked) view.setAlpha(alpha); }
From source file:com.travel.ac.view.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w . j a va 2s .c o m final Resources res = getResources(); mTextPaint.setColor(Color.BLACK); mTextPaint.setStrokeWidth(5); mTextPaint.setTextSize(40); //Load defaults from resources final float defaultLineHeight = res.getInteger(R.integer.default_line_height); final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); mTabLineHeight = a.getFloat(R.styleable.UnderlinePageIndicator_tab_line_height, defaultLineHeight); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.pierfrancescosoffritti.shrinkingimagelayout.parallaxScrimageView.ParallaxScrimageView.java
public ParallaxScrimageView(Context context, AttributeSet attrs) { super(context, attrs); if (attrs != null) { final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ParallaxScrimageView); if (a.hasValue(R.styleable.ParallaxScrimageView_scrimColor)) { scrimColor = a.getColor(R.styleable.ParallaxScrimageView_scrimColor, scrimColor); }/*from w ww. ja va 2s . co m*/ if (a.hasValue(R.styleable.ParallaxScrimageView_scrimAlpha)) { scrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_scrimAlpha, scrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_maxScrimAlpha)) { maxScrimAlpha = a.getFloat(R.styleable.ParallaxScrimageView_maxScrimAlpha, maxScrimAlpha); } if (a.hasValue(R.styleable.ParallaxScrimageView_parallaxFactor)) { parallaxFactor = a.getFloat(R.styleable.ParallaxScrimageView_parallaxFactor, parallaxFactor); } a.recycle(); } scrimPaint = new Paint(); scrimPaint.setColor(ColorUtils.modifyAlpha(scrimColor, scrimAlpha)); }
From source file:im.ene.lab.design.widget.swipecards.TinderView.java
public TinderView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StackView, defStyle, 0); MAX_VISIBLE = a.getInt(R.styleable.StackView_max_visible_children, MAX_VISIBLE); MIN_ADAPTER_STACK = a.getInt(R.styleable.StackView_min_adapter_stack, MIN_ADAPTER_STACK); ROTATION_DEGREES = a.getFloat(R.styleable.StackView_rotation_degrees, ROTATION_DEGREES); String layoutStyle = a.getString(R.styleable.StackView_layout_style); a.recycle();/*from w w w.j a va2s.co m*/ Style style = parseStyle(context, attrs, layoutStyle); mStyle = style == null ? new SimpleStyle() : style; }
From source file:me.oriley.vista.VistaEdgeEffectHelper.java
public VistaEdgeEffectHelper(@NonNull VistaEdgeEffectHost customEdgeEffectHost, @NonNull Context context, @Nullable AttributeSet attrs) { mHost = customEdgeEffectHost;/*from w w w. ja v a2 s .c o m*/ float thicknessScale = DEFAULT_THICKNESS_SCALE; float edgeScale = DEFAULT_EDGE_SCALE; boolean disableHotspot = false; boolean customColor = false; int initialColor = Color.WHITE; if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VistaView); if (a.hasValue(R.styleable.VistaView_vistaColor)) { customColor = true; initialColor = a.getColor(R.styleable.VistaView_vistaColor, initialColor); } disableHotspot = a.getBoolean(R.styleable.VistaView_vistaDisableHotspot, false); thicknessScale = a.getFloat(R.styleable.VistaView_vistaThicknessScale, DEFAULT_THICKNESS_SCALE); edgeScale = a.getFloat(R.styleable.VistaView_vistaEdgeScale, DEFAULT_EDGE_SCALE); a.recycle(); } // Couldn't get from attribute, try app compat accent color if (!customColor) { TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent }); initialColor = a.getColor(0, Color.WHITE); a.recycle(); } mInitialColor = initialColor; mDisableHotspot = disableHotspot; mThicknessScale = thicknessScale; mEdgeScale = edgeScale; }