List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:Main.java
public static int getNavigationBarrH(Context c) { Resources resources = c.getResources(); int identifier = resources.getIdentifier("navigation_bar_height", "dimen", "android"); return resources.getDimensionPixelOffset(identifier); }
From source file:Main.java
public static int getNavigationBarHeight(Context context) { Resources resources = context.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { return resources.getDimensionPixelOffset(resourceId); }//ww w .j a v a2 s .c o m return 0; }
From source file:com.android.datetimepicker.date.YearPickerView.java
/** * @param context//w w w. ja va2 s . co m */ public YearPickerView(Context context, DatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(context); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); }
From source file:com.redinput.datetimepickercompat.date.YearPickerView.java
/** * @param context/*from w w w.jav a 2 s . co m*/ */ public YearPickerView(Context context, DatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(context); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); installAccessibilityDelegate(); }
From source file:com.codetroopers.betterpickers.calendardatepicker.YearPickerView.java
/** * @param context//from w w w. j a va2 s . c om */ public YearPickerView(Context context, CalendarDatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(context); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); mBackgroundColor = R.color.circle_background; mCircleColor = R.color.bpBlue; mTextColor = R.color.ampm_text_color; }
From source file:com.tr4android.support.extension.picker.date.YearPickerView.java
public YearPickerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final LayoutParams frame = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame);/*from w ww. j a va 2s. c o m*/ final Resources res = context.getResources(); mChildSize = res.getDimensionPixelOffset(R.dimen.datepicker_year_label_height); setLayoutManager(new LinearLayoutManager(getContext())); mAdapter = new YearAdapter(getContext(), this); setAdapter(mAdapter); }
From source file:com.tct.mail.browse.SubjectAndFolderView.java
public SubjectAndFolderView(Context context, AttributeSet attrs) { super(context, attrs); //TS: yanhua.chen 2015-4-16 EMAIL BUGFIX_963186 ADD_S activity = (Activity) context;// ww w .j a v a 2s. co m //TS: yanhua.chen 2015-4-16 EMAIL BUGFIX_963186 ADD_E mVisibleFolders = false; mFolderDisplayer = new ConversationFolderDisplayer(getContext(), this); final Resources r = getResources(); mFolderPadding = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding); mFolderPaddingExtraWidth = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding_extra_width); mFolderPaddingAfter = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding_after); mRoundedCornerRadius = r.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius); mFolderSpanTextSize = r.getDimension(R.dimen.conversation_folder_font_size); mFolderMarginTop = r.getDimensionPixelOffset(R.dimen.conversation_folder_margin_top); }
From source file:com.microsoft.mimickeralarm.appcore.AlarmListItemTouchHelperCallback.java
@Override public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { View itemView = viewHolder.itemView; Resources resources = AlarmApplication.getAppContext().getResources(); Bitmap icon = BitmapFactory.decodeResource(resources, R.drawable.delete_trash_can); int iconPadding = resources.getDimensionPixelOffset(R.dimen.alarm_list_delete_icon_padding); int maxDrawWidth = (iconPadding * 2) + icon.getWidth(); Paint paint = new Paint(); paint.setColor(ContextCompat.getColor(AlarmApplication.getAppContext(), R.color.red)); int x = Math.round(Math.abs(dX)); // Reset the dismiss flag if the view resets to its default position if (x == 0) { mCanDismiss = false;/*from w ww .j ava2 s.c o m*/ } // If we have travelled beyond the icon area via direct user interaction // we will dismiss when we get a swipe callback. We do this to try to avoid // unwanted swipe dismissal if ((x > maxDrawWidth) && isCurrentlyActive) { mCanDismiss = true; } int drawWidth = Math.min(x, maxDrawWidth); // Cap the height of the drawable area to the selectable area - this improves the visual // for the first taller item in the alarm list int itemTop = itemView.getBottom() - resources.getDimensionPixelSize(R.dimen.alarm_list_item_height); if (dX > 0) { // Handle swiping to the right // Draw red background in area that we vacate up to maxDrawWidth canvas.drawRect((float) itemView.getLeft(), (float) itemTop, drawWidth, (float) itemView.getBottom(), paint); // Only draw icon when we've past the padding threshold if (x > iconPadding) { Rect destRect = new Rect(); destRect.left = itemView.getLeft() + iconPadding; destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2; int maxRight = destRect.left + icon.getWidth(); destRect.right = Math.min(x, maxRight); destRect.bottom = destRect.top + icon.getHeight(); // Only draw the appropriate parts of the bitmap as it is revealed Rect srcRect = null; if (x < maxRight) { srcRect = new Rect(); srcRect.top = 0; srcRect.left = 0; srcRect.bottom = icon.getHeight(); srcRect.right = x - iconPadding; } canvas.drawBitmap(icon, srcRect, destRect, paint); } } else { // Handle swiping to the left // Draw red background in area that we vacate up to maxDrawWidth canvas.drawRect((float) itemView.getRight() - drawWidth, (float) itemTop, (float) itemView.getRight(), (float) itemView.getBottom(), paint); // Only draw icon when we've past the padding threshold if (x > iconPadding) { int fromLeftX = itemView.getRight() - x; Rect destRect = new Rect(); destRect.right = itemView.getRight() - iconPadding; destRect.top = itemTop + (itemView.getBottom() - itemTop - icon.getHeight()) / 2; int maxFromLeft = destRect.right - icon.getWidth(); destRect.left = Math.max(fromLeftX, maxFromLeft); destRect.bottom = destRect.top + icon.getHeight(); // Only draw the appropriate parts of the bitmap as it is revealed Rect srcRect = null; if (fromLeftX > maxFromLeft) { srcRect = new Rect(); srcRect.top = 0; srcRect.right = icon.getWidth(); srcRect.bottom = icon.getHeight(); srcRect.left = srcRect.right - (x - iconPadding); } canvas.drawBitmap(icon, srcRect, destRect, paint); } } // Fade out the item as we swipe it float alpha = 1.0f - Math.abs(dX) / (float) itemView.getWidth(); itemView.setAlpha(alpha); itemView.setTranslationX(dX); } else { super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } }
From source file:com.android.tv.guide.ProgramItemView.java
private void initIfNeeded() { if (sVisibleThreshold != 0) { return;/* w w w . j a va2 s.com*/ } Resources res = getContext().getResources(); sVisibleThreshold = res.getDimensionPixelOffset(R.dimen.program_guide_table_item_visible_threshold); sItemPadding = res.getDimensionPixelOffset(R.dimen.program_guide_table_item_padding); ColorStateList programTitleColor = ColorStateList .valueOf(Utils.getColor(res, R.color.program_guide_table_item_program_title_text_color)); ColorStateList grayedOutProgramTitleColor = Utils.getColorStateList(res, R.color.program_guide_table_item_grayed_out_program_text_color); ColorStateList episodeTitleColor = ColorStateList .valueOf(Utils.getColor(res, R.color.program_guide_table_item_program_episode_title_text_color)); ColorStateList grayedOutEpisodeTitleColor = ColorStateList.valueOf( Utils.getColor(res, R.color.program_guide_table_item_grayed_out_program_episode_title_text_color)); int programTitleSize = res.getDimensionPixelSize(R.dimen.program_guide_table_item_program_title_font_size); int episodeTitleSize = res .getDimensionPixelSize(R.dimen.program_guide_table_item_program_episode_title_font_size); sProgramTitleStyle = new TextAppearanceSpan(null, 0, programTitleSize, programTitleColor, null); sGrayedOutProgramTitleStyle = new TextAppearanceSpan(null, 0, programTitleSize, grayedOutProgramTitleColor, null); sEpisodeTitleStyle = new TextAppearanceSpan(null, 0, episodeTitleSize, episodeTitleColor, null); sGrayedOutEpisodeTitleStyle = new TextAppearanceSpan(null, 0, episodeTitleSize, grayedOutEpisodeTitleColor, null); }
From source file:com.hrs.filltheform.dialog.FillTheFormDialog.java
public FillTheFormDialog(Context context) { this.context = context; // Get dialog dimensions Resources resources = context.getResources(); int normalDialogWidth = resources.getDimensionPixelOffset(R.dimen.normal_dialog_width); int normalDialogHeight = resources.getDimensionPixelOffset(R.dimen.normal_dialog_height); int expandedDialogWidth = resources.getDimensionPixelOffset(R.dimen.expanded_dialog_width); int expandedDialogHeight = resources.getDimensionPixelOffset(R.dimen.expanded_dialog_height); this.dialogInitialOffset = normalDialogWidth; // Set up the model this.model = new FillTheFormDialogModel(this); model.setPropertyChangedListener(this); model.setNormalDialogDimensions(normalDialogWidth, normalDialogHeight); model.setExpandedDialogDimensions(expandedDialogWidth, expandedDialogHeight); model.setStatusBarHeight(getStatusBarHeight()); // Prepare dialog view prepareDialogView();// w w w . j a v a 2 s .co m // Read fast mode config from shared prefs readFastModeConfigFromSharedPreferences(); // Init configuration variables this.configurationVariables = new ConfigurationVariables(context); }