本文整理匯總了Java中android.content.res.Resources.getDimensionPixelSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getDimensionPixelSize方法的具體用法?Java Resources.getDimensionPixelSize怎麽用?Java Resources.getDimensionPixelSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getDimensionPixelSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: adjustDropDownSizeAndPosition
import android.content.res.Resources; //導入方法依賴的package包/類
private void adjustDropDownSizeAndPosition() {
if (this.mDropDownAnchor.getWidth() > 1) {
int offset;
Resources res = getContext().getResources();
int anchorPadding = this.mSearchPlate.getPaddingLeft();
Rect dropDownPadding = new Rect();
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
int iconOffset = this.mIconifiedByDefault ? res.getDimensionPixelSize(R.dimen.abc_dropdownitem_icon_width) + res.getDimensionPixelSize(R.dimen.abc_dropdownitem_text_padding_left) : 0;
this.mSearchSrcTextView.getDropDownBackground().getPadding(dropDownPadding);
if (isLayoutRtl) {
offset = -dropDownPadding.left;
} else {
offset = anchorPadding - (dropDownPadding.left + iconOffset);
}
this.mSearchSrcTextView.setDropDownHorizontalOffset(offset);
this.mSearchSrcTextView.setDropDownWidth((((this.mDropDownAnchor.getWidth() + dropDownPadding.left) + dropDownPadding.right) + iconOffset) - anchorPadding);
}
}
示例2: AllAppsBackgroundDrawable
import android.content.res.Resources; //導入方法依賴的package包/類
public AllAppsBackgroundDrawable(Context context) {
Resources res = context.getResources();
mHand = new TransformedImageDrawable(context, res, R.drawable.ic_all_apps_bg_hand,
0.575f, 0.f, Gravity.CENTER_HORIZONTAL);
mIcons = new TransformedImageDrawable[4];
mIcons[0] = new TransformedImageDrawable(context, res, R.drawable.ic_all_apps_bg_icon_1,
0.375f, 0, Gravity.CENTER_HORIZONTAL);
mIcons[1] = new TransformedImageDrawable(context, res, R.drawable.ic_all_apps_bg_icon_2,
0.3125f, 0.2f, Gravity.CENTER_HORIZONTAL);
mIcons[2] = new TransformedImageDrawable(context, res, R.drawable.ic_all_apps_bg_icon_3,
0.475f, 0.26f, Gravity.CENTER_HORIZONTAL);
mIcons[3] = new TransformedImageDrawable(context, res, R.drawable.ic_all_apps_bg_icon_4,
0.7f, 0.125f, Gravity.CENTER_HORIZONTAL);
mWidth = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_width);
mHeight = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_height);
}
示例3: getUserBadge
import android.content.res.Resources; //導入方法依賴的package包/類
private synchronized Bitmap getUserBadge(UserHandle user, Context context) {
Bitmap badgeBitmap = mUserBadges.get(user);
if (badgeBitmap != null) {
return badgeBitmap;
}
final Resources res = context.getApplicationContext().getResources();
int badgeSize = res.getDimensionPixelSize(R.dimen.profile_badge_size);
badgeBitmap = Bitmap.createBitmap(badgeSize, badgeSize, Bitmap.Config.ARGB_8888);
Drawable drawable = context.getPackageManager().getUserBadgedDrawableForDensity(
new BitmapDrawable(res, badgeBitmap), user, new Rect(0, 0, badgeSize, badgeSize),
0);
if (drawable instanceof BitmapDrawable) {
badgeBitmap = ((BitmapDrawable) drawable).getBitmap();
} else {
badgeBitmap.eraseColor(Color.TRANSPARENT);
Canvas c = new Canvas(badgeBitmap);
drawable.setBounds(0, 0, badgeSize, badgeSize);
drawable.draw(c);
c.setBitmap(null);
}
mUserBadges.put(user, badgeBitmap);
return badgeBitmap;
}
示例4: init
import android.content.res.Resources; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
reducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
noTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
buttonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
buttonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
buttonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
dividerPaint = new Paint();
dividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
dividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
示例5: TabSwitcherDrawable
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Creates a new drawable, which allows to display the number of tabs, which are currently
* contained by a {@link TabSwitcher}.
*
* @param context
* The context, which should be used by the drawable, as an instance of the class {@link
* Context}. The context may not be null
*/
public TabSwitcherDrawable(@NonNull final Context context) {
ensureNotNull(context, "The context may not be null");
Resources resources = context.getResources();
size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
textSizeNormal =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
textSizeSmall =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
.mutate();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTextAlign(Align.CENTER);
paint.setTextSize(textSizeNormal);
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
label = Integer.toString(0);
int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
示例6: AbstractDragTabsEventHandler
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Creates a new drag handler, which allows to calculate the position and state of tabs on touch
* events.
*
* @param tabSwitcher
* The tab switcher, whose tabs' positions and states should be calculated by the drag
* handler, as an instance of the class {@link TabSwitcher}. The tab switcher may not be
* null
* @param arithmetics
* The arithmetics, which should be used to calculate the position, size and rotation of
* tabs, as an instance of the type {@link Arithmetics}. The arithmetics may not be
* null
* @param swipeEnabled
* True, if tabs can be swiped on the orthogonal axis, false otherwise
*/
public AbstractDragTabsEventHandler(@NonNull final TabSwitcher tabSwitcher,
@NonNull final Arithmetics arithmetics,
final boolean swipeEnabled) {
super(MIN_PRIORITY, tabSwitcher,
tabSwitcher.getResources().getDimensionPixelSize(R.dimen.drag_threshold));
ensureNotNull(arithmetics, "The arithmetics may not be null");
this.arithmetics = arithmetics;
this.swipeEnabled = swipeEnabled;
Resources resources = tabSwitcher.getResources();
this.swipeDragHelper =
new DragHelper(resources.getDimensionPixelSize(R.dimen.swipe_threshold));
this.callback = null;
ViewConfiguration configuration = ViewConfiguration.get(tabSwitcher.getContext());
this.minFlingVelocity = configuration.getScaledMinimumFlingVelocity();
this.maxFlingVelocity = configuration.getScaledMaximumFlingVelocity();
this.minSwipeVelocity = resources.getDimensionPixelSize(R.dimen.min_swipe_velocity);
resetDragging();
}
示例7: getNavigationBarHeight
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* 獲取NavigationBar的高度
*/
public static int getNavigationBarHeight(Context context) {
int navigationBarHeight = 0;
Resources rs = context.getApplicationContext().getResources();
int id = rs.getIdentifier("navigation_bar_height", "dimen", "android");
if (id > 0 && checkDeviceHasNavigationBar(context)) {
navigationBarHeight = rs.getDimensionPixelSize(id);
}
return navigationBarHeight;
}
示例8: getStatusBarHeight
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* 獲取頂部status bar 高度
*/
public static int getStatusBarHeight(Activity mActivity) {
Resources resources = mActivity.getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
int height = resources.getDimensionPixelSize(resourceId);
Log.i("height","Status height:" + height);
return height;
}
示例9: DualControlLayout
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Construct a new DualControlLayout.
*
* See {@link ViewGroup} for parameter details. attrs may be null if constructed dynamically.
*/
public DualControlLayout(Context context, AttributeSet attrs) {
super(context, attrs);
// Cache dimensions.
Resources resources = getContext().getResources();
mHorizontalMarginBetweenViews =
resources.getDimensionPixelSize(R.dimen.infobar_control_margin_between_items);
if (attrs != null) parseAttributes(attrs);
}
示例10: PageIndicatorLineCaret
import android.content.res.Resources; //導入方法依賴的package包/類
public PageIndicatorLineCaret(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Resources res = context.getResources();
mLinePaint = new Paint();
mLinePaint.setAlpha(0);
mLauncher = Launcher.getLauncher(context);
mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height);
setCaretDrawable(new CaretDrawable(context));
}
示例11: getInternalDimensionSize
import android.content.res.Resources; //導入方法依賴的package包/類
private int getInternalDimensionSize(Resources res, String key) {
int result = 0;
int resourceId = res.getIdentifier(key, "dimen", "android");
if (resourceId > 0) {
result = res.getDimensionPixelSize(resourceId);
}
return result;
}
示例12: getNavigationBarHeight
import android.content.res.Resources; //導入方法依賴的package包/類
public static int getNavigationBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}
示例13: getNavBarHeight
import android.content.res.Resources; //導入方法依賴的package包/類
public static int getNavBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}
示例14: CategoryListAdapter2
import android.content.res.Resources; //導入方法依賴的package包/類
public CategoryListAdapter2(Context context, CategoryTree<Category> categories) {
this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.categories = categories;
Resources resources = context.getResources();
this.expandedDrawable = resources.getDrawable(R.drawable.expander_ic_maximized);
this.collapsedDrawable = resources.getDrawable(R.drawable.expander_ic_minimized);
this.incomeColor = resources.getColor(R.color.category_type_income);
this.expenseColor = resources.getColor(R.color.category_type_expense);
this.levelPadding = resources.getDimensionPixelSize(R.dimen.category_padding);
recreatePlainList();
}
示例15: TouchInterceptor
import android.content.res.Resources; //導入方法依賴的package包/類
public TouchInterceptor(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
Resources res = getResources();
mItemHeightNormal = res.getDimensionPixelSize(R.dimen.normal_height);
mItemHeightHalf = mItemHeightNormal / 2;
mItemHeightExpanded = res.getDimensionPixelSize(R.dimen.expanded_height);
}