List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:com.eventer.app.view.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true;//from w w w.j a v a2s .c o m } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); super.setImageDrawable(mProgressDrawable); }
From source file:cn.com.elex.social_life.support.view.cjj.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true;//from w ww . j a v a 2 s . c o m } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); super.setImageDrawable(mProgressDrawable); }
From source file:cc.chenghong.vkagetorder.material.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mColors = new int[] { mProgressColor }; mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true;/*from w ww . ja va 2 s .co m*/ } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); mProgressDrawable.setStartEndTrim(0, (float) 0.75); super.setImageDrawable(mProgressDrawable); }
From source file:android.support.design.widget.FloatingActionButton.java
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton); mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint); mBackgroundTintMode = ViewUtils/*from w w w . jav a2s .c o m*/ .parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null); mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO); mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f); final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f); mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false); a.recycle(); mImageHelper = new AppCompatImageHelper(this); mImageHelper.loadFromAttributes(attrs, defStyleAttr); mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size); getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); getImpl().setElevation(elevation); getImpl().setPressedTranslationZ(pressedTranslationZ); }
From source file:cn.qbcbyb.library.view.VerticalPagerSlidingTabStrip.java
public VerticalPagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/* www . j a va2 s . c om*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); tabSelectedTextSize = tabTextSize; // get custom attrs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_android_textSize, tabTextSize); tabSelectedTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_selectedTextSize, tabTextSize); ColorStateList colorStateList = a.getColorStateList(R.styleable.PagerSlidingTabStrip_android_textColor); if (colorStateList != null) { tabTextColor = colorStateList; } a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:cn.qbcbyb.library.view.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from www .j ava 2 s. c o m setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); tabSelectedTextSize = tabTextSize; // get custom attrs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_android_textSize, tabTextSize); tabSelectedTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_selectedTextSize, tabTextSize); ColorStateList colorStateList = a.getColorStateList(R.styleable.PagerSlidingTabStrip_android_textColor); if (colorStateList != null) { tabTextColor = colorStateList; } a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.farbod.labelledspinner.LabelledSpinner.java
private void setUpLayout(Context context, AttributeSet attrs) { prepareLayout(context);//from w w w . j av a 2 s.c om mLabel = (TextView) getChildAt(0); mSpinner = (Spinner) getChildAt(1); mDivider = getChildAt(2); mErrorLabel = (TextView) getChildAt(3); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LabelledSpinner, 0, 0); String labelText = a.getString(R.styleable.LabelledSpinner_labelText); mWidgetColor = a.getColor(R.styleable.LabelledSpinner_widgetColor, ContextCompat.getColor(context, R.color.widget_labelled_spinner_default)); mLabel.setText(labelText); mLabel.setPadding(0, dpToPixels(16), 0, 0); mSpinner.setPadding(0, dpToPixels(8), 0, dpToPixels(8)); mSpinner.setOnItemSelectedListener(this); MarginLayoutParams dividerParams = (MarginLayoutParams) mDivider.getLayoutParams(); dividerParams.rightMargin = dpToPixels(4); dividerParams.bottomMargin = dpToPixels(8); mDivider.setLayoutParams(dividerParams); mLabel.setTextColor(mWidgetColor); mDivider.setBackgroundColor(mWidgetColor); alignLabelWithSpinnerItem(4); final CharSequence[] entries = a.getTextArray(R.styleable.LabelledSpinner_entries); if (entries != null) { setItemsArray(entries); } mDefaultErrorEnabled = a.getBoolean(R.styleable.LabelledSpinner_defaultErrorEnabled, false); mDefaultErrorText = getResources().getString(R.string.widget_labelled_spinner_errorText); a.recycle(); }
From source file:com.ekuater.labelchat.ui.widget.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*from w w w .j a v a2 s.c o m*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get custom attrs TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabTextSize, tabTextSize); tabTextColor = a.getColorStateList(R.styleable.PagerSlidingTabStrip_pstsTabTextColor); tabTypefaceStyle = indexToTextStyle(a.getInt(R.styleable.PagerSlidingTabStrip_pstsTabTextStyle, -1), tabTypefaceStyle); tabSelectedTypefaceStyle = indexToTextStyle( a.getInt(R.styleable.PagerSlidingTabStrip_pstsTabSelectedTextStyle, -1), tabSelectedTypefaceStyle); if (tabTextColor == null) { tabTextColor = ColorStateList.valueOf(0xFF666666); } a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1.0f); expandedTabLayoutParams.gravity = Gravity.CENTER; if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); // ThemeUtils.checkAppCompatTheme(context); setOrientation(VERTICAL);// w w w. j ava 2 s.c om setWillNotDraw(false); setAddStatesFromChildren(true); mInputFrame = new FrameLayout(context); mInputFrame.setAddStatesFromChildren(true); addView(mInputFrame); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator()); mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START); mHintExpanded = mCollapsingTextHelper.getExpansionFraction() == 1f; final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout); mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true); setHint(a.getText(R.styleable.TextInputLayout_android_hint)); mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true); if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) { mDefaultTextColor = mFocusedTextColor = a .getColorStateList(R.styleable.TextInputLayout_android_textColorHint); } final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1); if (hintAppearance != -1) { setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0)); } mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0); final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false); final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false); setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH)); mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0); mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance, 0); mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false); mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable); mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription); if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) { mHasPasswordToggleTintList = true; mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint); } if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) { mHasPasswordToggleTintMode = true; mPasswordToggleTintMode = ViewUtils .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null); } a.recycle(); setErrorEnabled(errorEnabled); setCounterEnabled(counterEnabled); applyPasswordToggleTint(); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // Make sure we're important for accessibility if we haven't been explicitly not ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate()); }
From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//w w w.jav a 2s. c o m setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); tabsContainer.setGravity(Gravity.START); addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); //underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); //dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); //tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); //tabTextSize = a.getDimensionPixelSize(0, tabTextSize); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); //underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); //dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); //underlineHeight = // a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); mTabTextColor = a.getColorStateList(R.styleable.PagerSlidingTabStrip_pstsTabTextColor); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); //dividerPaint = new Paint(); //dividerPaint.setAntiAlias(true); //dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }