List of usage examples for android.content.res TypedArray getDimensionPixelOffset
public int getDimensionPixelOffset(@StyleableRes int index, int defValue)
From source file:android.widget.Gallery.java
public Gallery(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mGestureDetector = new GestureDetector(context, this); mGestureDetector.setIsLongpressEnabled(true); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Gallery, defStyle, 0); int index = a.getInt(com.android.internal.R.styleable.Gallery_gravity, -1); if (index >= 0) { setGravity(index);// w ww.ja v a 2 s . co m } int animationDuration = a.getInt(com.android.internal.R.styleable.Gallery_animationDuration, -1); if (animationDuration > 0) { setAnimationDuration(animationDuration); } int spacing = a.getDimensionPixelOffset(com.android.internal.R.styleable.Gallery_spacing, 0); setSpacing(spacing); float unselectedAlpha = a.getFloat(com.android.internal.R.styleable.Gallery_unselectedAlpha, 0.5f); setUnselectedAlpha(unselectedAlpha); a.recycle(); // We draw the selected item last (because otherwise the item to the // right overlaps it) mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER; mGroupFlags |= FLAG_SUPPORT_STATIC_TRANSFORMATIONS; }
From source file:com.devbrackets.android.exomediademo.test.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); // <attr name="mlpb_inner_radius" format="dimension"/> // <attr name="mlpb_background_color" format="color"/> // <attr name="mlpb_progress_color" format="color"/> // <attr name="mlpb_progress_stoke_width" format="dimension"/> // <attr name="mlpb_arrow_width" format="dimension"/> // <attr name="mlpb_arrow_height" format="dimension"/> ////w w w .j ava 2 s.c o m // <attr name="mlpb_progress" format="integer"/> // <attr name="mlpb_max" format="integer"/> // // // <attr name="mlpb_progress_text_size" format="dimension"/> // <attr name="mlpb_progress_text_color" format="color"/> // // <attr name="mlpb_progress_text_offset" format="dimension"/> // // <attr name="mlpb_progress_text_visibility" format="enum"> // <enum name="visible" value="0"/> // <enum name="invisible" value="1"/> // </attr> 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[] { Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140), Color.rgb(140, 234, 255), Color.WHITE }; 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, false); 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; } 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:com.appsimobile.appsii.module.appsiagenda.MonthView.java
public MonthView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MonthView, 0, R.style.MonthViewStyle); mDayOfWeekTypeface = a.getString(R.styleable.MonthView_monthview_dayOfWeekTypeface); mMonthTitleTypeface = a.getString(R.styleable.MonthView_monthview_monthTitleTypeface); mDayTextColor = a.getColor(R.styleable.MonthView_monthview_dayTextColor, 0xFF999999); mTodayNumberColor = a.getColor(R.styleable.MonthView_monthview_todayNumberColor, 0xFF33b5e5); mDisabledDayTextColor = a.getColor(R.styleable.MonthView_monthview_disabledDayTextColor, 0xFFcccccc); mMonthTitleColor = a.getColor(R.styleable.MonthView_monthview_monthTitleColor, 0xFFFFFFFF); mMonthTitleBGColor = a.getColor(R.styleable.MonthView_monthview_monthTitleBGColor, 0xFFF2F2F2); MINI_DAY_NUMBER_TEXT_SIZE = a.getDimensionPixelSize(R.styleable.MonthView_monthview_miniDayNumberTextSize, 24);/*from w ww . j av a 2 s.c o m*/ MONTH_LABEL_TEXT_SIZE = a.getDimensionPixelSize(R.styleable.MonthView_monthview_monthLabelTextSize, 24); MONTH_DAY_LABEL_TEXT_SIZE = a.getDimensionPixelSize(R.styleable.MonthView_monthview_monthDayLabelTextSize, 24); MONTH_HEADER_SIZE = a.getDimensionPixelOffset(R.styleable.MonthView_monthview_headerSize, 24); DAY_SELECTED_CIRCLE_SIZE = a.getDimensionPixelSize(R.styleable.MonthView_monthview_daySelectedCircleSize, 24); mRowHeight = (a.getDimensionPixelOffset(R.styleable.MonthView_monthview_viewHeight, 24) - getMonthHeaderSize()) / MAX_NUM_ROWS; a.recycle(); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); if (!isInEditMode()) { // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; } else { mTouchHelper = null; } // Sets up any standard paints that will be used initView(); }
From source file:android.support.v7.widget.AbstractXpListPopupWindow.java
/** * Create a new, empty popup window capable of displaying items from a ListAdapter. * Backgrounds should be set using {@link #setBackgroundDrawable(Drawable)}. * * @param context Context used for contained views. * @param attrs Attributes from inflating parent views used to style the popup. * @param defStyleAttr Style attribute to read for default styling of popup content. * @param defStyleRes Style resource ID to use for default styling of popup content. *//*from w w w . ja v a 2 s.c om*/ public AbstractXpListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mContext = context; mHandler = new Handler(context.getMainLooper()); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPopupWindow, defStyleAttr, defStyleRes); mDropDownHorizontalOffset = a .getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0); mDropDownVerticalOffset = a .getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0); if (mDropDownVerticalOffset != 0) { mDropDownVerticalOffsetSet = true; } a.recycle(); int defaultMargin = Util.dpToPxOffset(context, 8); final TypedArray b = context.obtainStyledAttributes(attrs, R.styleable.XpListPopupWindow, defStyleAttr, defStyleRes); if (b.hasValue(R.styleable.XpListPopupWindow_android_layout_margin)) { int margin = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_margin, defaultMargin); mMargins.bottom = margin; mMargins.top = margin; mMargins.left = margin; mMargins.right = margin; } else { if (API_18 && b.hasValue(R.styleable.XpListPopupWindow_android_layout_marginEnd)) { int margin = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginEnd, 0); if (mLayoutDirection == LayoutDirection.RTL) { mMargins.left = margin; } else { mMargins.right = margin; } } else { mMargins.right = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginRight, defaultMargin); } if (API_18 && b.hasValue(R.styleable.XpListPopupWindow_android_layout_marginStart)) { int margin = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginStart, 0); if (mLayoutDirection == LayoutDirection.RTL) { mMargins.right = margin; } else { mMargins.left = margin; } } else { mMargins.left = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginLeft, defaultMargin); } mMargins.top = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginTop, defaultMargin); mMargins.bottom = b.getDimensionPixelOffset(R.styleable.XpListPopupWindow_android_layout_marginBottom, defaultMargin); } b.recycle(); mPopup = new AppCompatPopupWindow(context, attrs, defStyleAttr); mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); // Set the default layout direction to match the default locale one final Locale locale = mContext.getResources().getConfiguration().locale; mLayoutDirection = TextUtilsCompat.getLayoutDirectionFromLocale(locale); setAllowScrollingAnchorParent(false); }
From source file:com.yzy.supercleanmaster.views.SlidingLayer.java
/** * Constructor for the sliding layer.<br> * By default this panel will// w w w .j a v a 2 s . c om * <ol> * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_RIGHT}</li> * <li>Use no shadow drawable. (i.e. with size of 0)</li> * <li>Close when the panel is tapped</li> * <li>Open when the offset is tapped, but will have an offset of 0</li> * </ol> * * @param context a reference to an existing context * @param attrs attribute set constructed from attributes set in android .xml file * @param defStyle style res id */ public SlidingLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Style final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer); // Set the side of the screen setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_TOP)); // Sets the shadow drawable int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, INVALID_VALUE); if (shadowRes != INVALID_VALUE) { setShadowDrawable(shadowRes); } // Sets the shadow size mShadowSize = (int) ta.getDimension(R.styleable.SlidingLayer_shadowSize, 0); // Sets the ability to open or close the layer by tapping in any empty space changeStateOnTap = ta.getBoolean(R.styleable.SlidingLayer_changeStateOnTap, true); // How much of the view sticks out when closed mOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetDistance, 0); // Sets the size of the preview summary, if any mPreviewOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidingLayer_previewOffsetDistance, INVALID_VALUE); // If showing offset is greater than preview mode offset dimension, exception is thrown checkPreviewModeConsistency(); ta.recycle(); init(); }
From source file:com.android.contacts.common.list.ContactListItemView.java
public ContactListItemView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a; if (R.styleable.ContactListItemView != null) { // Read all style values a = getContext().obtainStyledAttributes(attrs, R.styleable.ContactListItemView); mPreferredHeight = a.getDimensionPixelSize(R.styleable.ContactListItemView_list_item_height, mPreferredHeight);//from w ww .j a v a2 s .c o m mActivatedBackgroundDrawable = a.getDrawable(R.styleable.ContactListItemView_activated_background); mGapBetweenImageAndText = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_gap_between_image_and_text, mGapBetweenImageAndText); mGapBetweenLabelAndData = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_gap_between_label_and_data, mGapBetweenLabelAndData); mPresenceIconMargin = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_presence_icon_margin, mPresenceIconMargin); mPresenceIconSize = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_presence_icon_size, mPresenceIconSize); mDefaultPhotoViewSize = a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_photo_size, mDefaultPhotoViewSize); mTextIndent = a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_text_indent, mTextIndent); mTextOffsetTop = a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_text_offset_top, mTextOffsetTop); mDataViewWidthWeight = a.getInteger(R.styleable.ContactListItemView_list_item_data_width_weight, mDataViewWidthWeight); mLabelViewWidthWeight = a.getInteger(R.styleable.ContactListItemView_list_item_label_width_weight, mLabelViewWidthWeight); mNameTextViewTextColor = a.getColor(R.styleable.ContactListItemView_list_item_name_text_color, mNameTextViewTextColor); mNameTextViewTextSize = (int) a.getDimension(R.styleable.ContactListItemView_list_item_name_text_size, (int) getResources().getDimension(R.dimen.contact_browser_list_item_text_size)); mVideoCallIconSize = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_video_call_icon_size, mVideoCallIconSize); mVideoCallIconMargin = a.getDimensionPixelOffset( R.styleable.ContactListItemView_list_item_video_call_icon_margin, mVideoCallIconMargin); setPaddingRelative(a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_left, 0), a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_top, 0), a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_right, 0), a.getDimensionPixelOffset(R.styleable.ContactListItemView_list_item_padding_bottom, 0)); a.recycle(); } mTextHighlighter = new TextHighlighter(Typeface.BOLD); if (R.styleable.Theme != null) { a = getContext().obtainStyledAttributes(R.styleable.Theme); mSecondaryTextColor = a.getColorStateList(R.styleable.Theme_android_textColorSecondary); a.recycle(); } mHeaderWidth = getResources().getDimensionPixelSize(R.dimen.contact_list_section_header_width); if (mActivatedBackgroundDrawable != null) { mActivatedBackgroundDrawable.setCallback(this); } mNameHighlightSequence = new ArrayList<HighlightSequence>(); mNumberHighlightSequence = new ArrayList<HighlightSequence>(); setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE); }
From source file:co.vn.e_alarm.customwiget.SlidingLayer.java
public SlidingLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Style/*from w ww. jav a 2s. co m*/ final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer); // Set the side of the screen setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_AUTO)); // Sets the shadow drawable int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, -1); if (shadowRes != -1) { setShadowDrawable(shadowRes); } // Sets the shadow width setShadowWidth((int) ta.getDimension(R.styleable.SlidingLayer_shadowWidth, 0)); // Sets the ability to close the layer by tapping in any empty space closeOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_closeOnTapEnabled, true); // Sets the ability to open the layout by tapping on any of the exposed closed layer openOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_openOnTapEnabled, true); // How much of the view sticks out when closed setOffsetWidth(ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetWidth, 0)); ta.recycle(); init(); }
From source file:com.hb.hkm.slidinglayer.SlidLayer.java
/** * Constructor for the sliding layer.<br> * By default this panel will//from w w w.j av a 2 s.c om * <ol> * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_RIGHT}</li> * <li>Use no shadow drawable. (i.e. with size of 0)</li> * <li>Close when the panel is tapped</li> * <li>Open when the offset is tapped, but will have an offset of 0</li> * </ol> * * @param context a reference to an existing context * @param attrs attribute set constructed from attributes set in android .xml file * @param defStyle style res id */ public SlidLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Style final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidLayer); // Set the side of the screen setStickTo(ta.getInt(R.styleable.SlidLayer_stickTo, STICK_TO_RIGHT)); // Sets the shadow drawable int shadowRes = ta.getResourceId(R.styleable.SlidLayer_shadowDrawable, INVALID_VALUE); if (shadowRes != INVALID_VALUE) { setShadowDrawable(shadowRes); } // Sets the shadow size mShadowSize = (int) ta.getDimension(R.styleable.SlidLayer_shadowSize, 0); // Sets the ability to open or close the layer by tapping in any empty space changeStateOnTap = ta.getBoolean(R.styleable.SlidLayer_changeStateOnTap, true); // How much of the view sticks out when closed mOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_offsetDistance, 0); // Sets the size of the preview summary, if any mPreviewOffsetDistance = ta.getDimensionPixelOffset(R.styleable.SlidLayer_previewOffsetDistance, INVALID_VALUE); // If showing offset is greater than preview mode offset dimension, exception is thrown checkPreviewModeConsistency(); ta.recycle(); init(); }
From source file:com.danilov.supermanga.core.view.SlidingLayer.java
/** * Constructor for the sliding layer.<br> * By default this panel will// w w w .j ava 2 s . co m * <ol> * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_AUTO}</li> * <li>Use no shadow drawable. (i.e. with width of 0)</li> * <li>Close when the panel is tapped</li> * <li>Open when the offset is tapped, but will have an offset of 0</li> * </ol> * @param context a reference to an existing context * @param attrs attribute set constructed from attributes set in android .xml file * @param defStyle style res id */ public SlidingLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Style final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer); // Set the side of the screen setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_AUTO)); // Sets the shadow drawable int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, -1); if (shadowRes != -1) { setShadowDrawable(shadowRes); } // Sets the shadow width setShadowWidth((int) ta.getDimension(R.styleable.SlidingLayer_shadowWidth, 0)); // Sets the ability to close the layer by tapping in any empty space closeOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_closeOnTapEnabled, true); // Sets the ability to open the layout by tapping on any of the exposed closed layer openOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_openOnTapEnabled, true); // How much of the view sticks out when closed setOffsetWidth(ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetWidth, 0)); ta.recycle(); init(); }
From source file:tp.stackoverflow.views.SlidingLayer.java
/** * Constructor for the sliding layer.<br> * By default this panel will/*from w ww. ja va2 s . c o m*/ * <ol> * <li>{@link #setStickTo(int)} with param {@link #STICK_TO_AUTO}</li> * <li>Use no shadow drawable. (i.e. with width of 0)</li> * <li>Close when the panel is tapped</li> * <li>Open when the offset is tapped, but will have an offset of 0</li> * </ol> * @param context a reference to an existing context * @param attrs attribute set constructed from attributes set in android .xml file * @param defStyle style res id */ public SlidingLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Style final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer); // Set the side of the screen setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_RIGHT)); // Sets the shadow drawable int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, -1); if (shadowRes != -1) { setShadowDrawable(shadowRes); } // Sets the shadow width setShadowWidth((int) ta.getDimension(R.styleable.SlidingLayer_shadowWidth, 0)); // Sets the ability to close the layer by tapping in any empty space closeOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_closeOnTapEnabled, true); // Sets the ability to open the layout by tapping on any of the exposed closed layer openOnTapEnabled = ta.getBoolean(R.styleable.SlidingLayer_openOnTapEnabled, true); // How much of the view sticks out when closed setOffsetWidth(ta.getDimensionPixelOffset(R.styleable.SlidingLayer_offsetWidth, 0)); ta.recycle(); init(); }