List of usage examples for android.content.res Resources getDimensionPixelSize
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException
From source file:com.android.gallery3d.v5.filtershow.category.CategoryView.java
public CategoryView(Context context) { super(context); setOnClickListener(this); Resources res = getResources(); mSelectionStroke = res.getDimensionPixelSize(R.dimen.thumbnail_margin); mSelectPaint = new Paint(); mSelectPaint.setStyle(Paint.Style.FILL); mSelectionColor = res.getColor(R.color.filtershow_category_selection); mSpacerColor = res.getColor(R.color.filtershow_categoryview_text); mSelectPaint.setColor(mSelectionColor); mBorderPaint = new Paint(mSelectPaint); mBorderPaint.setColor(Color.BLACK); mBorderStroke = mSelectionStroke / 2; }
From source file:com.andryr.musicplayer.images.ArtistImageCache.java
private ArtistImageCache(Context context) { super();//from ww w. j av a2 s. co m mContext = context; mDatabase = new ArtistImageDb(mContext); final Resources res = mContext.getResources(); mLargeImageSize = res.getDimensionPixelSize(R.dimen.artist_image_req_width); mThumbSize = res.getDimensionPixelSize(R.dimen.art_thumbnail_size); }
From source file:org.xbmc.kore.utils.UIUtils.java
/** * Fills the standard cast info list, consisting of a {@link android.widget.GridLayout} * with actor images and a Textview with the name and the role of the additional cast. * The number of actor presented on the {@link android.widget.GridLayout} is controlled * through the global setting, and only actors with images are presented. * The rest are presented in the additionalCastView TextView * * @param activity Activity/* w w w. j av a 2 s. c o m*/ * @param castList Cast list * @param castListView GridLayout on which too show actors that have images */ public static void setupCastInfo(final Activity activity, List<VideoType.Cast> castList, GridLayout castListView, final Intent allCastActivityLaunchIntent) { HostManager hostManager = HostManager.getInstance(activity); Resources resources = activity.getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(displayMetrics); View.OnClickListener castListClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Utils.openImdbForPerson(activity, (String) v.getTag()); } }; castListView.removeAllViews(); int numColumns = castListView.getColumnCount(); int numRows = resources.getInteger(R.integer.cast_grid_view_rows); int maxCastPictures = numColumns * numRows; int layoutMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.remote_content_hmargin); int imageMarginPx = 2 * resources.getDimensionPixelSize(R.dimen.image_grid_margin); int imageWidth = (displayMetrics.widthPixels - layoutMarginPx - numColumns * imageMarginPx) / numColumns; int imageHeight = (int) (imageWidth * 1.5); for (int i = 0; i < Math.min(castList.size(), maxCastPictures); i++) { VideoType.Cast actor = castList.get(i); View castView = LayoutInflater.from(activity).inflate(R.layout.grid_item_cast, castListView, false); ImageView castPicture = (ImageView) castView.findViewById(R.id.picture); TextView castName = (TextView) castView.findViewById(R.id.name); TextView castRole = (TextView) castView.findViewById(R.id.role); castView.getLayoutParams().width = imageWidth; castView.getLayoutParams().height = imageHeight; castView.setTag(actor.name); UIUtils.loadImageWithCharacterAvatar(activity, hostManager, actor.thumbnail, actor.name, castPicture, imageWidth, imageHeight); if ((i == maxCastPictures - 1) && (castList.size() > i + 1)) { View castNameGroup = castView.findViewById(R.id.cast_name_group); View allCastGroup = castView.findViewById(R.id.all_cast_group); TextView remainingCastCount = (TextView) castView.findViewById(R.id.remaining_cast_count); castNameGroup.setVisibility(View.GONE); allCastGroup.setVisibility(View.VISIBLE); remainingCastCount.setText(String.format(activity.getString(R.string.remaining_cast_count), castList.size() - maxCastPictures + 1)); castView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.startActivity(allCastActivityLaunchIntent); activity.overridePendingTransition(R.anim.activity_in, R.anim.activity_out); } }); } else { castName.setText(actor.name); castRole.setText(actor.role); castView.setOnClickListener(castListClickListener); } castListView.addView(castView); } }
From source file:com.atwal.wakeup.battery.util.Utilities.java
public static int getInternalDimensionSize(Resources res, String key) { int result = 0; int resourceId = res.getIdentifier(key, "dimen", "android"); if (resourceId > 0) { result = res.getDimensionPixelSize(resourceId); }/* w ww. j av a 2 s. c om*/ return result; }
From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java
public StepPagerStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); gravity = a.getInteger(0, gravity);/*from ww w . ja va 2 s. c o m*/ a.recycle(); Resources res = getResources(); tabWidth = res.getDimensionPixelSize(R.dimen.step_pager_tab_width); tabHeight = res.getDimensionPixelSize(R.dimen.step_pager_tab_height); indicatorSpacing = res.getDimensionPixelSize(R.dimen.step_pager_tab_spacing); radius = 14; nonCurrentRadius = 10; nextTabPaint = new Paint(); nextTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.step_pager_next_tab_color)); selectedTabPaint = new Paint(); selectedTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent)); prevTabPaint = new Paint(); prevTabPaint.setColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryLight)); }
From source file:com.jungle.toolbaractivity.layout.HorizontalSwipeBackLayout.java
private void initLayout(Context context) { Resources res = getResources(); mShadowWidth = res.getDimensionPixelSize(R.dimen.activity_edge_shadow_width); mEdgeShadowDrawable = res.getDrawable(R.drawable.activity_left_edge_shadow); mTriggerSlideSlop = (int) (1.5f * ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration.get(getContext()))); }
From source file:android.support.design.internal.BottomNavigationItemView.java
public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final Resources res = getResources(); int inactiveLabelSize = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_text_size); int activeLabelSize = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_text_size); mDefaultMargin = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_margin); mShiftAmount = inactiveLabelSize - activeLabelSize; mScaleUpFactor = 1f * activeLabelSize / inactiveLabelSize; mScaleDownFactor = 1f * inactiveLabelSize / activeLabelSize; LayoutInflater.from(context).inflate(R.layout.design_bottom_navigation_item, this, true); setBackgroundResource(R.drawable.design_bottom_navigation_item_background); mIcon = (ImageView) findViewById(R.id.icon); mSmallLabel = (TextView) findViewById(R.id.smallLabel); mLargeLabel = (TextView) findViewById(R.id.largeLabel); }
From source file:id.co.datascrip.dtswarehousesystem.custom.StepPagerStrip.java
public StepPagerStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mGravity = a.getInteger(0, mGravity); a.recycle();// ww w .j av a 2 s. c om final Resources res = getResources(); mTabWidth = res.getDimensionPixelSize(R.dimen.step_pager_tab_width); mTabHeight = res.getDimensionPixelSize(R.dimen.step_pager_tab_height); mTabSpacing = res.getDimensionPixelSize(R.dimen.step_pager_tab_spacing); mPrevTabPaint = new Paint(); mPrevTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_previous_tab_color)); mSelectedTabPaint = new Paint(); mSelectedTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_selected_tab_color)); mSelectedLastTabPaint = new Paint(); mSelectedLastTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_selected_last_tab_color)); mNextTabPaint = new Paint(); mNextTabPaint.setColor(ContextCompat.getColor(context, R.color.step_pager_next_tab_color)); }
From source file:com.android.adam.navigation.BottomNavigationItemView.java
public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final Resources res = getResources(); int inactiveLabelSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_text_size); int activeLabelSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_active_text_size); mDefaultMargin = res.getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_margin); mShiftAmount = inactiveLabelSize - activeLabelSize; mScaleUpFactor = 1f * activeLabelSize / inactiveLabelSize; mScaleDownFactor = 1f * inactiveLabelSize / activeLabelSize; LayoutInflater.from(context).inflate(android.support.design.R.layout.design_bottom_navigation_item, this, true);/* w w w . j a v a2 s . c o m*/ setBackgroundResource(android.support.design.R.drawable.design_bottom_navigation_item_background); mIcon = (ImageView) findViewById(android.support.design.R.id.icon); mSmallLabel = (TextView) findViewById(android.support.design.R.id.smallLabel); mLargeLabel = (TextView) findViewById(android.support.design.R.id.largeLabel); }
From source file:cn.jay.widget.BottomNavigationItemView.java
public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final Resources res = getResources(); int inactiveLabelSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_text_size); int activeLabelSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_active_text_size); mDefaultMargin = res.getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_margin); mShiftAmount = inactiveLabelSize - activeLabelSize; mScaleUpFactor = 1f * activeLabelSize / inactiveLabelSize; mScaleDownFactor = 1f * inactiveLabelSize / activeLabelSize; LayoutInflater.from(context).inflate(android.support.design.R.layout.design_bottom_navigation_item, this, true);/*from w w w. ja v a2 s. co m*/ setBackgroundResource(android.support.design.R.drawable.design_bottom_navigation_item_background); mIcon = (ImageView) findViewById(android.support.design.R.id.icon); mSmallLabel = (TextView) findViewById(android.support.design.R.id.smallLabel); mLargeLabel = (TextView) findViewById(android.support.design.R.id.largeLabel); }