List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); sMiniDayNumberTextSize = res.getDimensionPixelSize(R.dimen.day_number_size); sMonthLabelTextSize = res.getDimensionPixelSize(R.dimen.month_label_size); sMonthDayLabelTextSize = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); sMonthHeaderSize = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); sDaySelectedCircleSize = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - sMonthHeaderSize) / MAX_NUM_ROWS;/*w ww . ja v a 2s . c o m*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.diandi.widget.googledatetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/*from www . j a va 2 s . c om*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.doomonafireball.betterpickers.calendardatepicker.MonthView.java
public MonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;// w ww .j a v a 2s. c om // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.deange.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.HOLOYOLO); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;/*from w w w . j av a 2s.c o m*/ // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.doomonafireball.betterpickers.calendardatepicker.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); // < mMonthTitleColor = res.getColor(android.R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); // < mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); sMiniDayNumberTextSize = res.getDimensionPixelSize(R.dimen.day_number_size); sMonthLabelTextSize = res.getDimensionPixelSize(R.dimen.month_label_size); sMonthDayLabelTextSize = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); sMonthHeaderSize = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); sDaySelectedCircleSize = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - sMonthHeaderSize) / MAX_NUM_ROWS;//from w w w. j a v a 2s.c o m // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:org.holoeverywhere.widget.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DateTimePicker, defStyle, R.style.Holo_DateTimePicker); mDayTextColor = a.getColor(R.styleable.DateTimePicker_dateDayTextColor, 0); mTodayNumberColor = a.getColor(R.styleable.DateTimePicker_dateTodayColor, 0); mMonthTitleColor = a.getColor(R.styleable.DateTimePicker_dateMonthTitleColor, 0); mSelectedCircleColor = a.getColor(R.styleable.DateTimePicker_dateCircleColor, 0); a.recycle();//from w w w . j a va2 s. c o m mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.date_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.date_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.date_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.date_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.date_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_time_picker_size) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS; // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.android.mail.browse.ConversationItemView.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Utils.traceBeginSection("CIVC.measure"); final int wSize = MeasureSpec.getSize(widthMeasureSpec); final int currentMode = mActivity.getViewMode().getMode(); if (wSize != mViewWidth || mPreviousMode != currentMode) { mViewWidth = wSize;// www.j a va2s . com mPreviousMode = currentMode; } mHeader.viewWidth = mViewWidth; mConfig.updateWidth(wSize).setLayoutDirection(ViewCompat.getLayoutDirection(this)); Resources res = getResources(); mHeader.standardScaledDimen = res.getDimensionPixelOffset(R.dimen.standard_scaled_dimen); mCoordinates = ConversationItemViewCoordinates.forConfig(mContext, mConfig, mAdapter.getCoordinatesCache()); if (mPhotoBitmap != null) { mPhotoRect.set(0, 0, mCoordinates.contactImagesWidth, mCoordinates.contactImagesHeight); } final int h = (mAnimatedHeightFraction != 1.0f) ? Math.round(mAnimatedHeightFraction * mCoordinates.height) : mCoordinates.height; setMeasuredDimension(mConfig.getWidth(), h); Utils.traceEndSection(); }
From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java
/** * Generates a phone number shortcut icon. Adds an overlay describing the type of the phone * number, and if there is a photo also adds the call action icon. *///from ww w .j av a 2s .c o m private Bitmap generatePhoneNumberIcon(Drawable photo, int phoneType, String phoneLabel, int actionResId) { final Resources r = mContext.getResources(); final float density = r.getDisplayMetrics().density; Bitmap phoneIcon = ((BitmapDrawable) r.getDrawableForDensity(actionResId, mIconDensity)).getBitmap(); Bitmap icon = generateQuickContactIcon(photo); Canvas canvas = new Canvas(icon); // Copy in the photo Paint photoPaint = new Paint(); photoPaint.setDither(true); photoPaint.setFilterBitmap(true); Rect dst = new Rect(0, 0, mIconSize, mIconSize); // Create an overlay for the phone number type CharSequence overlay = Phone.getTypeLabel(r, phoneType, phoneLabel); if (overlay != null) { TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); textPaint.setTextSize(r.getDimension(R.dimen.shortcut_overlay_text_size)); textPaint.setColor(r.getColor(R.color.textColorIconOverlay)); textPaint.setShadowLayer(4f, 0, 2f, r.getColor(R.color.textColorIconOverlayShadow)); final FontMetricsInt fmi = textPaint.getFontMetricsInt(); // First fill in a darker background around the text to be drawn final Paint workPaint = new Paint(); workPaint.setColor(mOverlayTextBackgroundColor); workPaint.setStyle(Paint.Style.FILL); final int textPadding = r.getDimensionPixelOffset(R.dimen.shortcut_overlay_text_background_padding); final int textBandHeight = (fmi.descent - fmi.ascent) + textPadding * 2; dst.set(0, mIconSize - textBandHeight, mIconSize, mIconSize); canvas.drawRect(dst, workPaint); overlay = TextUtils.ellipsize(overlay, textPaint, mIconSize, TruncateAt.END); final float textWidth = textPaint.measureText(overlay, 0, overlay.length()); canvas.drawText(overlay, 0, overlay.length(), (mIconSize - textWidth) / 2, mIconSize - fmi.descent - textPadding, textPaint); } // Draw the phone action icon as an overlay Rect src = new Rect(0, 0, phoneIcon.getWidth(), phoneIcon.getHeight()); int iconWidth = icon.getWidth(); dst.set(iconWidth - ((int) (20 * density)), -1, iconWidth, ((int) (19 * density))); canvas.drawBitmap(phoneIcon, src, dst, photoPaint); canvas.setBitmap(null); return icon; }
From source file:com.codetroopers.betterpickers.calendardatepicker.MonthView.java
public MonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColorEnabled = res.getColor(R.color.date_picker_text_normal); mDayTextColorDisabled = res.getColor(R.color.date_picker_text_disabled); mTodayNumberColor = res.getColor(R.color.bpBlue); mDayBackgroundColorDisabled = res.getColor(R.color.bpDarker_red); mMonthTitleColor = res.getColor(R.color.date_picker_text_normal); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;//from w w w . j a va2s . c o m // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.android.datetimepicker.date.MonthView.java
public MonthView(Context context, AttributeSet attr) { super(context, attr); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mDisabledDayTextColor = res.getColor(R.color.date_picker_text_disabled); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS;//from ww w. jav a 2 s .c o m // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }