List of usage examples for android.content.res TypedArray getFloat
public float getFloat(@StyleableRes int index, float defValue)
From source file:com.hgdendi.contactslist.common.IndexBar.java
/****************** * common/*ww w . ja v a 2s .c o m*/ ******************/ private void initSetting(Context context, AttributeSet attrs) { mOnTouchingLetterChangeListener = getDummyListener(); mNavigators = new ArrayList<>(0); mFocusIndex = -1; TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexBar); float textSize = typedArray.getDimension(R.styleable.IndexBar_letterSize, 8); int letterColor = typedArray.getColor(R.styleable.IndexBar_letterColor, ContextCompat.getColor(getContext(), android.R.color.white)); mLetterSpacingExtra = typedArray.getFloat(R.styleable.IndexBar_letterSpacingExtra, 1.4f); int focusLetterColor = typedArray.getColor(R.styleable.IndexBar_focusLetterColor, ContextCompat.getColor(getContext(), android.R.color.white)); typedArray.recycle(); mPaint = new Paint(); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setAntiAlias(true); mPaint.setColor(letterColor); mPaint.setTextSize(textSize); mFocusPaint = new Paint(); mFocusPaint.setTypeface(Typeface.DEFAULT_BOLD); mFocusPaint.setAntiAlias(true); mFocusPaint.setFakeBoldText(true); mFocusPaint.setTextSize(textSize); mFocusPaint.setColor(focusLetterColor); }
From source file:com.tienpx.videodrag.DraggablePanel.java
/** * Initialize the xml configuration based on styleable attributes * * @param attrs to analyze./*from w ww . j a v a 2 s.c o m*/ */ 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); this.enableClickToMaximize = attributes.getBoolean( R.styleable.draggable_panel_enable_click_to_maximize_panel, DEFAULT_ENABLE_CLICK_TO_MAXIMIZE); this.enableClickToMinimize = attributes.getBoolean( R.styleable.draggable_panel_enable_click_to_minimize_panel, DEFAULT_ENABLE_CLICK_TO_MINIMIZE); this.enableTouchListener = attributes.getBoolean(R.styleable.draggable_panel_enable_touch_listener_panel, DEFAULT_ENABLE_TOUCH_LISTENER); attributes.recycle(); }
From source file:nuclei.ui.view.GlideImageView.java
void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlideImageView, defStyleAttr, defStyleRes);//from w ww. j a v a 2 s.c o m mDownloadState = sDefaultDownloadState; mCircle = a.getBoolean(R.styleable.GlideImageView_circle, false); mRatio = a.getFloat(R.styleable.GlideImageView_ratio, 0); mRadius = a.getDimensionPixelSize(R.styleable.GlideImageView_radius, 0); mPlaceholderId = a.getResourceId(R.styleable.GlideImageView_placeholder, 0); if (a.hasValue(R.styleable.GlideImageView_border_color)) { int borderColor = a.getColor(R.styleable.GlideImageView_border_color, 0); float borderWidth = a.getDimensionPixelSize(R.styleable.GlideImageView_border_width, 0); setBorder(borderColor, borderWidth); } String uri = a.getString(R.styleable.GlideImageView_url); boolean preload = a.getBoolean(R.styleable.GlideImageView_preload, true); a.recycle(); if (preload) { if (!isInEditMode()) { if (uri == null) { setPlaceHolder(); } else setImageURI(uri); } else setPlaceHolder(); } }
From source file:mbanje.kurt.fabbutton.FabButton.java
protected void init(Context context, AttributeSet attrs, int defStyle) { View v = View.inflate(context, R.layout.widget_fab_button, this); setClipChildren(false);/*from w w w . jav a 2 s. c o m*/ circle = (CircleImageView) v.findViewById(R.id.fabbutton_circle); ring = (ProgressRingView) v.findViewById(R.id.fabbutton_ring); circle.setFabViewListener(this); ring.setFabViewListener(this); int color = Color.BLACK; int progressColor = Color.BLACK; int animDuration = 4000; int icon = -1; float maxProgress = 0; float progress = 0; if (attrs != null) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView); color = a.getColor(R.styleable.CircleImageView_android_color, Color.BLACK); progressColor = a.getColor(R.styleable.CircleImageView_fbb_progressColor, Color.BLACK); progress = a.getFloat(R.styleable.CircleImageView_android_progress, 0f); maxProgress = a.getFloat(R.styleable.CircleImageView_android_max, 100f); indeterminate = a.getBoolean(R.styleable.CircleImageView_android_indeterminate, false); autostartanim = a.getBoolean(R.styleable.CircleImageView_fbb_autoStart, true); animDuration = a.getInteger(R.styleable.CircleImageView_android_indeterminateDuration, animDuration); icon = a.getResourceId(R.styleable.CircleImageView_android_src, icon); ringWidthRatio = a.getFloat(R.styleable.CircleImageView_fbb_progressWidthRatio, ringWidthRatio); endBitmapResource = a.getResourceId(R.styleable.CircleImageView_fbb_endBitmap, R.drawable.ic_fab_complete); showEndBitmap = a.getBoolean(R.styleable.CircleImageView_fbb_showEndBitmap, false); hideProgressOnComplete = a.getBoolean(R.styleable.CircleImageView_fbb_hideProgressOnComplete, false); circle.setShowShadow(a.getBoolean(R.styleable.CircleImageView_fbb_showShadow, true)); a.recycle(); } circle.setColor(color); circle.setShowEndBitmap(showEndBitmap); circle.setRingWidthRatio(ringWidthRatio); ring.setProgressColor(progressColor); ring.setProgress(progress, true); ring.setMaxProgress(maxProgress); ring.setAutostartanim(autostartanim); ring.setAnimDuration(animDuration); ring.setRingWidthRatio(ringWidthRatio); ring.setIndeterminate(indeterminate); if (icon != -1) { circle.setIcon(icon, endBitmapResource); } }
From source file:mbanje.kurt.fabbutton.FabButton.java
protected void init(Context context, AttributeSet attrs, int defStyle) { View v = View.inflate(context, R.layout.widget_fab_button, this); setClipChildren(false);//from ww w . ja v a 2 s . co m circle = (CircleImageView) v.findViewById(R.id.fabbutton_circle); ring = (ProgressRingView) v.findViewById(R.id.fabbutton_ring); circle.setFabViewListener(this); ring.setFabViewListener(this); int color = Color.BLACK; int progressColor = Color.BLACK; int animDuration = 4000; int icon = -1; float maxProgress = 0; float progress = 0; if (attrs != null) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView); color = a.getColor(R.styleable.CircleImageView_android_color, Color.BLACK); progressColor = a.getColor(R.styleable.CircleImageView_fbb_progressColor, Color.BLACK); progress = a.getFloat(R.styleable.CircleImageView_android_progress, 0f); maxProgress = a.getFloat(R.styleable.CircleImageView_android_max, 100f); indeterminate = a.getBoolean(R.styleable.CircleImageView_android_indeterminate, false); autostartanim = a.getBoolean(R.styleable.CircleImageView_fbb_autoStart, true); animDuration = a.getInteger(R.styleable.CircleImageView_android_indeterminateDuration, animDuration); icon = a.getResourceId(R.styleable.CircleImageView_android_src, icon); ringWidthRatio = a.getFloat(R.styleable.CircleImageView_fbb_progressWidthRatio, ringWidthRatio); endBitmapResource = a.getResourceId(R.styleable.CircleImageView_fbb_endBitmap, R.drawable.ic_fab_complete); showEndBitmap = a.getBoolean(R.styleable.CircleImageView_fbb_showEndBitmap, false); hideProgressOnComplete = a.getBoolean(R.styleable.CircleImageView_fbb_hideProgressOnComplete, false); circle.setShowShadow(a.getBoolean(R.styleable.CircleImageView_fbb_showShadow, true)); a.recycle(); } circle.setColor(color); circle.setShowEndBitmap(showEndBitmap); circle.setRingWidthRatio(ringWidthRatio); ring.setProgressColor(progressColor); ring.setProgress(progress); ring.setMaxProgress(maxProgress); ring.setAutostartanim(autostartanim); ring.setAnimDuration(animDuration); ring.setRingWidthRatio(ringWidthRatio); ring.setIndeterminate(indeterminate); if (icon != -1) { circle.setIcon(icon, endBitmapResource); } }
From source file:com.findme.views.ExpandableTextView.java
private void init(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES);/*from w w w . j a v a 2s .co m*/ mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mAnimAlphaStart = typedArray.getFloat(R.styleable.ExpandableTextView_animAlphaStart, DEFAULT_ANIM_ALPHA_START); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); if (mExpandDrawable == null) { mExpandDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_expand, null); } if (mCollapseDrawable == null) { mCollapseDrawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_action_collapse, null); } typedArray.recycle(); }
From source file:com.wenhui.syncedListView.lib.SyncedListLayout.java
private void init(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SyncedListLayout); try {/*w w w.j av a 2 s . co m*/ mLeftListId = a.getResourceId(R.styleable.SyncedListLayout_left_id, 0); mRightListId = a.getResourceId(R.styleable.SyncedListLayout_right_id, 0); mLeftScrollFactor = a.getFloat(R.styleable.SyncedListLayout_left_scroll_factor, 1f); mRightScrollFactor = a.getFloat(R.styleable.SyncedListLayout_right_scroll_factor, 1f); } finally { a.recycle(); } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metric = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metric); mAnimationVelocity = (int) (DEFAULT_VELOCITY * metric.density); gestureDetector = new GestureDetectorCompat(context, gestureListener); mScroller = new Scroller(context); mAnimationRunnable = new AnimationRunnable(context); mFlingRunnable = new FlingRunnable(); }
From source file:com.qs.qswlw.view.Mypager.UltraViewPager.java
private void initView(Context context, AttributeSet attrs) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.UltraViewPager); setAutoScroll(ta.getInt(R.styleable.UltraViewPager_upv_autoscroll, 0)); setInfiniteLoop(ta.getBoolean(R.styleable.UltraViewPager_upv_infiniteloop, false)); setRatio(ta.getFloat(R.styleable.UltraViewPager_upv_ratio, Float.NaN)); setScrollMode(ScrollMode.getScrollMode(ta.getInt(R.styleable.UltraViewPager_upv_scrollmode, 0))); disableScrollDirection(//from www .j av a 2s . co m ScrollDirection.getScrollDirection(ta.getInt(R.styleable.UltraViewPager_upv_disablescroll, 0))); setMultiScreen(ta.getFloat(R.styleable.UltraViewPager_upv_multiscreen, 1f)); setAutoMeasureHeight(ta.getBoolean(R.styleable.UltraViewPager_upv_automeasure, false)); setItemRatio(ta.getFloat(R.styleable.UltraViewPager_upv_itemratio, Float.NaN)); ta.recycle(); }
From source file:co.ceryle.segmentedbutton.SegmentedButton.java
private void getAttributes(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SegmentedButton); imageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_imageTint, -1); hasButtonImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_imageTint); buttonImageScale = typedArray.getFloat(R.styleable.SegmentedButton_sb_imageScale, 1); selectedImageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedImageTint, 0); hasSelectedImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedImageTint); selectedTextColor = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedTextColor, 0); hasTextColorOnSelection = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedTextColor); rippleColor = typedArray.getColor(R.styleable.SegmentedButton_sb_rippleColor, 0); hasRipple = typedArray.hasValue(R.styleable.SegmentedButton_sb_rippleColor); typeface = typedArray.getString(R.styleable.SegmentedButton_sb_typeface); try {/* w w w . j ava2 s. c o m*/ hasWeight = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_weight); buttonWeight = typedArray.getFloat(R.styleable.SegmentedButton_android_layout_weight, -1); buttonWidth = typedArray.getDimensionPixelSize(R.styleable.SegmentedButton_android_layout_width, 0); hasWidth = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_width); } catch (Exception ex) { Log.d("SegmentedButton", ex.toString()); } typedArray.recycle(); }
From source file:com.github.nitrico.mapviewpager.MapViewPager.java
private void initialize(Context context, AttributeSet attrs) { mapOffset = dp(32);/*w ww. ja va 2 s .c om*/ if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MapViewPager, 0, 0); try { markersAlpha = a.getFloat(R.styleable.MapViewPager_markersAlpha, DEFAULT_ALPHA); pagerWeight = a.getInteger(R.styleable.MapViewPager_viewPagerWeight, 1); mapWeight = a.getInteger(R.styleable.MapViewPager_mapWeight, 1); mapGravity = a.getInteger(R.styleable.MapViewPager_mapGravity, 1); mapOffset = a.getDimensionPixelSize(R.styleable.MapViewPager_mapOffset, mapOffset); mapPaddingLeft = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingLeft, 0); mapPaddingTop = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingTop, 0); mapPaddingRight = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingRight, 0); mapPaddingBottom = a.getDimensionPixelSize(R.styleable.MapViewPager_mapPaddingBottom, 0); } finally { a.recycle(); } } LayoutInflater inflater = LayoutInflater.from(context); switch (mapGravity) { case 0: inflater.inflate(R.layout.mapviewpager_left, this); break; case 1: inflater.inflate(R.layout.mapviewpager_top, this); break; case 2: inflater.inflate(R.layout.mapviewpager_right, this); break; case 3: inflater.inflate(R.layout.mapviewpager_bottom, this); break; } }