List of usage examples for android.content.res TypedArray getDimensionPixelSize
public int getDimensionPixelSize(@StyleableRes int index, int defValue)
From source file:com.actionbarsherlock.internal.widget.IcsLinearLayout.java
public IcsLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);/*w w w. j a v a 2 s.c o m*/ a.recycle(); }
From source file:angeloid.dreamnarae.SwipeyTabs.java
public SwipeyTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeyTabs, defStyle, 0); mBottomBarColor = a.getColor(R.styleable.SwipeyTabs_bottomBarColor, mBottomBarColor); mBottomBarHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_bottomBarHeight, 2); mTabIndicatorHeight = a.getDimensionPixelSize(R.styleable.SwipeyTabs_tabIndicatorHeight, 3); a.recycle();/*from w w w. j a v a 2s .c om*/ init(); }
From source file:com.example.xiangnanzhang.smarttab.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; ColorStateList textColors;/*from w w w . j a va 2 s. c o m*/ int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density); int textMinWidth = (int) (30 * density); boolean clickable = TAB_CLICKABLE; int titleOffset = (int) (TITLE_OFFSET_DIPS * density); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0); textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor); textHorizontalPadding = a.getDimensionPixelSize( R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding); // this.titleOffset = titleOffset; this.internalTabClickListener = clickable ? new InternalTabClickListener() : null; // this.distributeEvenly = distributeEvenly; // this.distributeEvenly = true; this.tabStrip = new SmartTabStrip(context, attrs); // tabStrip.setDividerColors(R.color.transparent); // Make sure that the Tab Strips fills this View setFillViewport(false); addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); }
From source file:com.chess.genesis.view.SwipeTabs.java
public SwipeTabs(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeTabs, defStyle, 0); mBottomBarColor = a.getColor(R.styleable.SwipeTabs_bottomBarColor, mBottomBarColor); mBottomBarHeight = a.getDimensionPixelSize(R.styleable.SwipeTabs_bottomBarHeight, 2); mTabIndicatorHeight = a.getDimensionPixelSize(R.styleable.SwipeTabs_tabIndicatorHeight, 3); a.recycle();//from w w w . ja va 2 s . c om init(); }
From source file:com.ameron32.apps.tapnotes._trial.ui.CollapsingTitleLayout.java
public void setTextAppearance(int resId) { TypedArray atp = getContext().obtainStyledAttributes(resId, R.styleable.CollapsingTextAppearance); mTextPaint.setColor(atp.getColor(R.styleable.CollapsingTextAppearance_android_textColor, Color.WHITE)); mCollapsedTitleTextSize = atp.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, 0);//from ww w . j a va 2 s. c o m atp.recycle(); recalculate(); }
From source file:com.ijiaban.tabslide.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //scroll/* www. j a v a2 s .c om*/ setFillViewport(true); //ondraw 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(); // TypedValue.applyDimension 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); // (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); // tabTextSize = a.getDimensionPixelSize(0, tabTextSize); // tabTextColor = a.getColor(1, tabTextColor); 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); 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.asc_ii.bangnote.bigbang.BigBangLayout.java
private void readAttribute(AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.BigBangLayout); mItemSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_itemSpace, getResources().getDimensionPixelSize(R.dimen.big_bang_default_item_space)); mLineSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_lineSpace, getResources().getDimensionPixelSize(R.dimen.big_bang_default_line_space)); mItemTextSize = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_textSize, getResources().getDimensionPixelSize(R.dimen.big_bang_default_text_size)); typedArray.recycle();/*w ww.j a va 2 s . c o m*/ mActionBarBottomHeight = mLineSpace; mActionBarTopHeight = getResources().getDimensionPixelSize(R.dimen.big_bang_action_bar_height); } mActionBar = new BigBangActionBar(getContext()); mActionBar.setVisibility(View.GONE); mActionBar.setActionListener(this); addView(mActionBar, 0); setClipChildren(false); mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); if (isInEditMode()) { // ? addTextItem("BigBang"); addTextItem(""); addTextItem(""); addTextItem("?"); addTextItem(""); addTextItem(""); addTextItem(""); addTextItem("?"); } }
From source file:com.baoyz.bigbang.core.BigBangLayout.java
private void readAttribute(AttributeSet attrs) { if (attrs != null) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.BigBangLayout); mItemSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_itemSpace, getResources().getDimensionPixelSize(R.dimen.big_bang_default_item_space)); mLineSpace = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_lineSpace, getResources().getDimensionPixelSize(R.dimen.big_bang_default_line_space)); mItemTextSize = typedArray.getDimensionPixelSize(R.styleable.BigBangLayout_textSize, getResources().getDimensionPixelSize(R.dimen.big_bang_default_text_size)); typedArray.recycle();/*from w w w . j av a 2 s . com*/ mActionBarBottomHeight = mLineSpace; mActionBarTopHeight = getResources().getDimensionPixelSize(R.dimen.big_bang_action_bar_height); } // TODO mActionBar = new BigBangActionBar(getContext()); mActionBar.setVisibility(View.GONE); mActionBar.setActionListener(this); addView(mActionBar, 0); setClipChildren(false); mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); if (isInEditMode()) { // ? addTextItem("BigBang"); addTextItem(""); addTextItem(""); addTextItem("?"); addTextItem(""); addTextItem(""); addTextItem(""); addTextItem("?"); } }
From source file:com.azhansy.linky.view.PagerSlidingIndicator.java
public PagerSlidingIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*from www.j a v a2 s . c o m*/ setWillNotDraw(false); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); backgroundStrokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, backgroundStrokeWidth, dm); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingIndicator); shouldExpand = a.getBoolean(R.styleable.PagerSlidingIndicator_shouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_scrollOffset, scrollOffset); backgroundStrokeColor = a.getColor(R.styleable.PagerSlidingIndicator_background_stroke_color, backgroundStrokeColor); backgroundStrokeWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_background_stroke_width, backgroundStrokeWidth); backgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_background_color, backgroundColor); checkedBackgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_checked_background_color, checkedBackgroundColor); a.recycle(); // backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); backgroundPaint.setColor(backgroundColor); backgroundPaint.setStyle(Style.FILL); // checkedBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); checkedBackgroundPaint.setColor(checkedBackgroundColor); checkedBackgroundPaint.setStyle(Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); }
From source file:com.facebook.FacebookButtonBase.java
@SuppressLint("ResourceType") private void parseCompoundDrawableAttributes(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) { final int attrsResources[] = { android.R.attr.drawableLeft, android.R.attr.drawableTop, android.R.attr.drawableRight, android.R.attr.drawableBottom, android.R.attr.drawablePadding, }; final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, attrsResources, defStyleAttr, defStyleRes);//from w ww . jav a 2 s. c o m try { setCompoundDrawablesWithIntrinsicBounds(a.getResourceId(0, 0), a.getResourceId(1, 0), a.getResourceId(2, 0), a.getResourceId(3, 0)); setCompoundDrawablePadding(a.getDimensionPixelSize(4, 0)); } finally { a.recycle(); } }