List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:com.canyinghao.canrefresh.CanRefreshLayout.java
public CanRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CanRefreshLayout, defStyleAttr, 0); try {// ww w . j av a 2 s .co m final int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == R.styleable.CanRefreshLayout_can_enabled_up) { setRefreshEnabled(a.getBoolean(attr, true)); } else if (attr == R.styleable.CanRefreshLayout_can_enabled_down) { setLoadMoreEnabled(a.getBoolean(attr, true)); } else if (attr == R.styleable.CanRefreshLayout_can_style_up) { mHeadStyle = a.getInt(attr, CLASSIC); } else if (attr == R.styleable.CanRefreshLayout_can_style_down) { mFootStyle = a.getInt(attr, CLASSIC); } else if (attr == R.styleable.CanRefreshLayout_can_friction) { setFriction(a.getFloat(attr, DEFAULT_FRICTION)); } else if (attr == R.styleable.CanRefreshLayout_can_duration) { mDuration = a.getInt(attr, DEFAULT_DURATION); } else if (attr == R.styleable.CanRefreshLayout_can_smooth_duration) { mSmoothDuration = a.getInt(attr, DEFAULT_SMOOTH_DURATION); } else if (attr == R.styleable.CanRefreshLayout_can_smooth_length) { mSmoothLength = a.getInt(attr, DEFAULT_SMOOTH_LENGTH); } } } finally { a.recycle(); } }
From source file:com.android.hcframe.DraggableGridViewPager.java
public DraggableGridViewPager(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (attrs != null) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.dragGridView, defStyle, 0); mShowDivider = typedArray.getBoolean(R.styleable.dragGridView_dividerShowed, false); mDividerColor = typedArray.getColor(R.styleable.dragGridView_dividerColor, 0); mDividerPaddingTop = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerPaddingTop, 0); mDividerPaddingBottom = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerPaddingBottom, 0);//ww w .jav a 2s.com mDividerWidth = typedArray.getDimensionPixelSize(R.styleable.dragGridView_dividerWidth, 1); typedArray.recycle(); HcLog.D(TAG + " divider color = " + mDividerColor); } initDraggableGridViewPager(); }
From source file:android.support.v7.app.WindowDecorActionBar.java
private void init(View decor) { mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(R.id.decor_content_parent); if (mOverlayLayout != null) { mOverlayLayout.setActionBarVisibilityCallback(this); }//ww w.j av a 2 s .c o m mDecorToolbar = getDecorToolbar(decor.findViewById(R.id.action_bar)); mContextView = (ActionBarContextView) decor.findViewById(R.id.action_context_bar); mContainerView = (ActionBarContainer) decor.findViewById(R.id.action_bar_container); if (mDecorToolbar == null || mContextView == null || mContainerView == null) { throw new IllegalStateException( getClass().getSimpleName() + " can only be used " + "with a compatible window decor layout"); } mContext = mDecorToolbar.getContext(); // This was initially read from the action bar style final int current = mDecorToolbar.getDisplayOptions(); final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0; if (homeAsUp) { mDisplayHomeAsUpSet = true; } ActionBarPolicy abp = ActionBarPolicy.get(mContext); setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp); setHasEmbeddedTabs(abp.hasEmbeddedTabs()); final TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0); if (a.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) { setHideOnContentScrollEnabled(true); } final int elevation = a.getDimensionPixelSize(R.styleable.ActionBar_elevation, 0); if (elevation != 0) { setElevation(elevation); } a.recycle(); }
From source file:android.support.v7ox.app.WindowDecorActionBar.java
private void init(View decor) { mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(R.id.decor_content_parent); if (mOverlayLayout != null) { mOverlayLayout.setActionBarVisibilityCallback(this); }//from w w w.j a va 2 s . com mDecorToolbar = getDecorToolbar(decor.findViewById(R.id.action_bar)); mContextView = (ActionBarContextView) decor.findViewById(R.id.action_context_bar); mContainerView = (ActionBarContainer) decor.findViewById(R.id.action_bar_container); if (mDecorToolbar == null || mContextView == null || mContainerView == null) { throw new IllegalStateException( getClass().getSimpleName() + " can only be used " + "with a compatible window decor layout"); } mContext = mDecorToolbar.getContext(); // This was initially read from the action bar style final int current = mDecorToolbar.getDisplayOptions(); final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0; if (homeAsUp) { mDisplayHomeAsUpSet = true; } ActionBarPolicy abp = ActionBarPolicy.get(mContext); setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp); setHasEmbeddedTabs(abp.hasEmbeddedTabs()); final TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle_ox, 0); if (a.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) { setHideOnContentScrollEnabled(true); } final int elevation = a.getDimensionPixelSize(R.styleable.ActionBar_elevation, 0); if (elevation != 0) { setElevation(elevation); } a.recycle(); }
From source file:android.support.v7.internal.app.WindowDecorActionBar.java
private void init(View decor) { mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(R.id.decor_content_parent); if (mOverlayLayout != null) { mOverlayLayout.setActionBarVisibilityCallback(this); }//from www .j a v a 2s.c om mDecorToolbar = getDecorToolbar(decor.findViewById(R.id.action_bar)); mContextView = (ActionBarContextView) decor.findViewById(R.id.action_context_bar); mContainerView = (ActionBarContainer) decor.findViewById(R.id.action_bar_container); mSplitView = (ActionBarContainer) decor.findViewById(R.id.split_action_bar); if (mDecorToolbar == null || mContextView == null || mContainerView == null) { throw new IllegalStateException( getClass().getSimpleName() + " can only be used " + "with a compatible window decor layout"); } mContext = mDecorToolbar.getContext(); mContextDisplayMode = mDecorToolbar.isSplit() ? CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL; // This was initially read from the action bar style final int current = mDecorToolbar.getDisplayOptions(); final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0; if (homeAsUp) { mDisplayHomeAsUpSet = true; } ActionBarPolicy abp = ActionBarPolicy.get(mContext); setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp); setHasEmbeddedTabs(abp.hasEmbeddedTabs()); final TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0); if (a.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) { setHideOnContentScrollEnabled(true); } final int elevation = a.getDimensionPixelSize(R.styleable.ActionBar_elevation, 0); if (elevation != 0) { setElevation(elevation); } a.recycle(); }
From source file:com.cyan.widget.refreshlayout.RefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context/*from w w w. j av a2 s . c o m*/ * @param attrs */ public RefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density); mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density); createProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); // the absolute offset has to take into account that the circle starts at an offset mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density; mHeaderTotalDragDistance = mSpinnerFinalOffset; mProgressBar = new SwipeProgressBar(this); mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT); }
From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context/*from w w w .j av a 2 s. c om*/ * @param attrs */ public RefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density); mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density); createProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); // the absolute offset has to take into account that the community starts at an offset mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density; mHeaderTotalDragDistance = mSpinnerFinalOffset; mProgressBar = new SwipeProgressBar(this); mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT); }
From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java
public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); final DisplayMetrics dm = getResources().getDisplayMetrics(); final float density = dm.density; int tabBackgroundResId = NO_ID; int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density); int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density); boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY; int customTabLayoutId = NO_ID; int customTabTextViewId = NO_ID; boolean clickable = TAB_CLICKABLE; int titleOffset = (int) (TITLE_OFFSET_DIPS * density); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0); tabBackgroundResId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId);//from w w w . ja v a 2 s . c o m textHorizontalPadding = a.getDimensionPixelSize( R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding); textMinWidth = a.getDimensionPixelSize(R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth); customTabLayoutId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId); customTabTextViewId = a.getResourceId(R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId); distributeEvenly = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly); clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable); titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset); a.recycle(); this.titleOffset = titleOffset; this.tabViewBackgroundResId = tabBackgroundResId; this.tabViewTextHorizontalPadding = textHorizontalPadding; this.tabViewTextMinWidth = textMinWidth; this.internalTabClickListener = clickable ? new InternalTabClickListener() : null; this.distributeEvenly = distributeEvenly; if (customTabLayoutId != NO_ID) { setCustomTabView(customTabLayoutId, customTabTextViewId); } this.tabStrip = new SmartTabStrip(context, attrs); if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) { throw new UnsupportedOperationException( "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support"); } // Make sure that the Tab Strips fills this View setFillViewport(!tabStrip.isIndicatorAlwaysInCenter()); addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
From source file:codetail.graphics.drawables.LayerDrawable.java
/** * Initializes the constant state from the values in the typed array. *///from www . j a v a 2 s .c om private void updateStateFromTypedArray(Theme theme, TypedArray a, TypedValue[] extracted) { final LayerState state = mLayerState; // Account for any configuration changes. state.mChangingConfigurations |= TypedArrayCompat.getChangingConfigurations(a); // Extract the theme attributes, if any. state.mThemeAttrs = TypedArrayCompat.extractThemeAttrs(a); mOpacityOverride = a.getInt(R.styleable.LayerDrawable_android_opacity, mOpacityOverride); state.mAutoMirrored = a.getBoolean(R.styleable.LayerDrawable_android_autoMirrored, state.mAutoMirrored); state.mPaddingMode = a.getInteger(R.styleable.LayerDrawable_android_paddingMode, state.mPaddingMode); }
From source file:com.dkstudio.icorrect.practice.speaking.ui.custom.MaterialProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressBar, defStyleAttr, 0);/*from w ww . j a v a 2 s . c om*/ final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.MaterialProgressBar_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.MaterialProgressBar_progress_color, DEFAULT_CIRCLE_BG_LIGHT); mInnerRadius = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.MaterialProgressBar_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.MaterialProgressBar_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.MaterialProgressBar_enable_circle_background, true); mProgress = a.getInt(R.styleable.MaterialProgressBar_progress, 0); mMax = a.getInt(R.styleable.MaterialProgressBar_max, 100); int textVisible = a.getInt(R.styleable.MaterialProgressBar_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true; } 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); }