List of usage examples for android.content.res Resources getDimensionPixelSize
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException
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 w w . j av a 2s. co 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:org.getlantern.firetweet.provider.FiretweetDataProvider.java
private Bitmap getProfileImageForNotification(final String profile_image_url) { final Context context = getContext(); final Resources res = context.getResources(); final int w = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_width); final int h = res.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); final File profile_image_file = mImagePreloader.getCachedImageFile(profile_image_url); final Bitmap profile_image = profile_image_file != null && profile_image_file.isFile() ? BitmapFactory.decodeFile(profile_image_file.getPath()) : null;/*w ww . j a va 2 s . co m*/ if (profile_image != null) return Bitmap.createScaledBitmap(profile_image, w, h, true); return Bitmap.createScaledBitmap(BitmapFactory.decodeResource(res, R.mipmap.ic_launcher), w, h, true); }
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 a v a 2 s . co 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.rockerhieu.emojicon.EmojiconsPopup.java
/** * Call this function to resize the emoji popup according to your soft keyboard size *///from w w w . j a va 2 s .c om public void setSizeForSoftKeyboard() { rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (isOpened) { return; } Rect r = new Rect(); rootView.getWindowVisibleDisplayFrame(r); int screenHeight = getUsableScreenHeight(); int heightDifference = screenHeight - (r.bottom - r.top); Resources resources = mContext.getResources(); int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android"); //add support translucent status bar ??? // if (!((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) && (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP))) { // if (statusBarId > 0) { // heightDifference -= mContext.getResources() // .getDimensionPixelSize(statusBarId); // // Log.e("keyboard height", "resourceId > 0" + heightDifference); // } // } if (statusBarId > 0) { heightDifference -= resources.getDimensionPixelSize(statusBarId); } //Resolved using http://stackoverflow.com/a/16608481/2853322 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { int navBarId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); boolean hasMenuKey; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { hasMenuKey = ViewConfiguration.get(mContext).hasPermanentMenuKey(); } else hasMenuKey = true; //Skip has menu key below ICS boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); //This is a hack for lollipop if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { hasBackKey = false; } if (navBarId > 0 && !hasMenuKey && !hasBackKey) { heightDifference -= resources.getDimensionPixelSize(navBarId); } } // int statusBarResourceId = mContext.getResources() // .getIdentifier("status_bar_height", // "dimen", "android"); // if (statusBarResourceId > 0) { // heightDifference -= mContext.getResources() // .getDimensionPixelSize(statusBarResourceId); // } // // int navBarResourceId = mContext.getResources() // .getIdentifier("navigation_bar_height", // "dimen", "android"); // if (navBarResourceId > 0) { // heightDifference -= mContext.getResources().getDimensionPixelSize(navBarResourceId); // } if (heightDifference > 150) { keyBoardHeight = heightDifference; setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); if (!isOpened) { if (onSoftKeyboardOpenCloseListener != null) onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); } isOpened = true; if (pendingOpen) { showAtBottom(); pendingOpen = false; } } else { isOpened = false; if (onSoftKeyboardOpenCloseListener != null) onSoftKeyboardOpenCloseListener.onKeyboardClose(); } } }); }
From source file:com.lite.android.launcher3.allapps.AllAppsGridAdapter.java
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher;//from ww w. j av a 2s . co m mApps = apps; mEmptySearchMessage = res.getString(R.string.all_apps_loading_message); mGridSizer = new GridSpanSizer(); mGridLayoutMgr = new AppsGridLayoutManager(launcher); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(launcher); mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; mSectionNamesMargin = mSectionStrategy == AllAppsContainerView.SECTION_STRATEGY_GRID ? res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin) : res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin_with_sections); mAllAppsTextColor = mGridTheme == AllAppsContainerView.GRID_THEME_DARK ? res.getColor(R.color.quantum_panel_text_color_dark) : res.getColor(R.color.quantum_panel_text_color); mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset); mSectionTextPaint = new Paint(); mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size)); int sectionTextColorId = mGridTheme == AllAppsContainerView.GRID_THEME_DARK ? R.color.all_apps_grid_section_text_color_dark : R.color.all_apps_grid_section_text_color; mSectionTextPaint.setColor(res.getColor(sectionTextColorId)); mSectionTextPaint.setAntiAlias(true); mPredictedAppsDividerPaint = new Paint(); mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); mPredictionBarDividerOffset = res.getDimensionPixelSize(R.dimen.all_apps_prediction_bar_divider_offset); // Resolve the market app handling additional searches PackageManager pm = launcher.getPackageManager(); ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""), PackageManager.MATCH_DEFAULT_ONLY); if (marketInfo != null) { mMarketAppName = marketInfo.loadLabel(pm).toString(); } mRemoteFolderManager = launcher.getRemoteFolderManager(); }
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 .jav a 2 s . 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:android.support.v7.app.MediaRouteControllerDialog.java
/** * Sets the width of the dialog. Also called when configuration changes. *//*from w w w .ja va 2s . com*/ void updateLayout() { int width = MediaRouteDialogHelper.getDialogWidth(mContext); getWindow().setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT); View decorView = getWindow().getDecorView(); mDialogContentWidth = width - decorView.getPaddingLeft() - decorView.getPaddingRight(); Resources res = mContext.getResources(); mVolumeGroupListItemIconSize = res .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_icon_size); mVolumeGroupListItemHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_item_height); mVolumeGroupListMaxHeight = res.getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_max_height); // Ensure the mArtView is updated. mArtIconBitmap = null; mArtIconUri = null; update(false); }
From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java
/** * Sets up the text and style properties for painting. *//* ww w. ja v a2s .co m*/ private void initPaints(Resources res) { final String monthTypeface = res.getString(R.string.sp_date_picker_month_typeface); final String dayOfWeekTypeface = res.getString(R.string.sp_date_picker_day_of_week_typeface); final String dayTypeface = res.getString(R.string.sp_date_picker_day_typeface); final int monthTextSize = res.getDimensionPixelSize(R.dimen.sp_date_picker_month_text_size); final int dayOfWeekTextSize = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_of_week_text_size); final int dayTextSize = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_text_size); mMonthPaint.setAntiAlias(true); mMonthPaint.setTextSize(monthTextSize); mMonthPaint.setTypeface(Typeface.create(monthTypeface, 0)); mMonthPaint.setTextAlign(Paint.Align.CENTER); mMonthPaint.setStyle(Paint.Style.FILL); mDayOfWeekPaint.setAntiAlias(true); mDayOfWeekPaint.setTextSize(dayOfWeekTextSize); mDayOfWeekPaint.setTypeface(Typeface.create(dayOfWeekTypeface, 0)); mDayOfWeekPaint.setTextAlign(Paint.Align.CENTER); mDayOfWeekPaint.setStyle(Paint.Style.FILL); mDaySelectorPaint.setAntiAlias(true); mDaySelectorPaint.setStyle(Paint.Style.FILL); mDayHighlightPaint.setAntiAlias(true); mDayHighlightPaint.setStyle(Paint.Style.FILL); mDayRangeSelectorPaint.setAntiAlias(true); mDayRangeSelectorPaint.setStyle(Paint.Style.FILL); mDayPaint.setAntiAlias(true); mDayPaint.setTextSize(dayTextSize); mDayPaint.setTypeface(Typeface.create(dayTypeface, 0)); mDayPaint.setTextAlign(Paint.Align.CENTER); mDayPaint.setStyle(Paint.Style.FILL); }
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 . ja v a 2s .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.commonsware.cwac.crossport.design.widget.FloatingActionButton.java
private int getSizeDimension(@Size final int size) { final Resources res = getResources(); // If custom size is set, return it if (mCustomSize != NO_CUSTOM_SIZE) { return mCustomSize; }//from w w w. j a v a2 s . c o m switch (size) { case SIZE_AUTO: // If we're set to auto, grab the size from resources and refresh final int width = res.getConfiguration().screenWidthDp; final int height = res.getConfiguration().screenHeightDp; return Math.max(width, height) < AUTO_MINI_LARGEST_SCREEN_WIDTH ? getSizeDimension(SIZE_MINI) : getSizeDimension(SIZE_NORMAL); case SIZE_MINI: return res.getDimensionPixelSize(R.dimen.design_fab_size_mini); case SIZE_NORMAL: default: return res.getDimensionPixelSize(R.dimen.design_fab_size_normal); } }