List of usage examples for android.content.res Resources getDimensionPixelSize
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException
From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);//from w w w. jav a2 s . c o m view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:org.onebusaway.android.map.googlemapsv2.StopOverlay.java
/** * Cache the BitmapDescriptors that hold the images used for icons *//*from w w w . j av a 2 s . co m*/ private static final void loadIcons() { // Initialize variables used for all marker icons Resources r = Application.get().getResources(); mPx = r.getDimensionPixelSize(R.dimen.map_stop_shadow_size_6); mArrowWidthPx = mPx / 2f; // half the stop icon size mArrowHeightPx = mPx / 3f; // 1/3 the stop icon size float arrowSpacingReductionPx = mPx / 10f; mBuffer = mArrowHeightPx - arrowSpacingReductionPx; // Set offset used to position the image for markers (see getX/YPercentOffsetForDirection()) // This allows the current selection marker to land on the middle of the stop marker circle mPercentOffset = (mBuffer / (mPx + mBuffer)) * 0.5f; mArrowPaintStroke = new Paint(); mArrowPaintStroke.setColor(Color.WHITE); mArrowPaintStroke.setStyle(Paint.Style.STROKE); mArrowPaintStroke.setStrokeWidth(1.0f); mArrowPaintStroke.setAntiAlias(true); bus_stop_icons[0] = createBusStopIcon(NORTH); bus_stop_icons[1] = createBusStopIcon(NORTH_WEST); bus_stop_icons[2] = createBusStopIcon(WEST); bus_stop_icons[3] = createBusStopIcon(SOUTH_WEST); bus_stop_icons[4] = createBusStopIcon(SOUTH); bus_stop_icons[5] = createBusStopIcon(SOUTH_EAST); bus_stop_icons[6] = createBusStopIcon(EAST); bus_stop_icons[7] = createBusStopIcon(NORTH_EAST); bus_stop_icons[8] = createBusStopIcon(NO_DIRECTION); }
From source file:com.example.android.tvleanback.presenter.CardPresenter.java
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { Video video = (Video) item;/*from ww w .ja v a2 s .c om*/ ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setTitleText(video.title); cardView.setContentText(video.studio); if (video.cardImageUrl != null) { // Set card size from dimension resources. Resources res = cardView.getResources(); int width = res.getDimensionPixelSize(R.dimen.card_width); int height = res.getDimensionPixelSize(R.dimen.card_height); cardView.setMainImageDimensions(width, height); Glide.with(cardView.getContext()).load(video.cardImageUrl).error(mDefaultCardImage) .into(cardView.getMainImageView()); } }
From source file:com.google.cloud.android.dialogflow.ui.BubbleView.java
@SuppressWarnings("WrongConstant") public BubbleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTintIncoming = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.incoming)); mTintOutgoing = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.outgoing)); final Resources resources = getResources(); mPaddingVertical = resources.getDimensionPixelSize(R.dimen.bubble_padding_vertical); mPaddingHorizontalShort = resources.getDimensionPixelSize(R.dimen.bubble_padding_horizontal_short); mPaddingHorizontalLong = resources.getDimensionPixelSize(R.dimen.bubble_padding_horizontal_long); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleView); setDirection(a.getInt(R.styleable.BubbleView_direction, DIRECTION_INCOMING)); a.recycle();/* www . j av a 2 s . com*/ }
From source file:com.aengbee.android.leanback.presenter.CardPresenter.java
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { Video video = (Video) item;//from ww w . j a v a 2 s. c o m ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setTitleText(video.title); cardView.setContentText(video.description); if (video.category.equals("TJ")) cardView.setBadgeImage(viewHolder.view.getResources().getDrawable(R.drawable.ic_tj_128x128, null)); if (video.category.equals("KY")) cardView.setBadgeImage(viewHolder.view.getResources().getDrawable(R.drawable.ic_ky_128x128_3, null)); if (video.cardImageUrl != null) { // Set card size from dimension resources. Resources res = cardView.getResources(); int width = res.getDimensionPixelSize(R.dimen.card_width); int height = res.getDimensionPixelSize(R.dimen.card_height); cardView.setMainImageDimensions(width, height); Glide.with(cardView.getContext()).load(video.cardImageUrl).error(mDefaultCardImage) .into(cardView.getMainImageView()); } }
From source file:se.johan.wendler.ui.view.DragGripView.java
public DragGripView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mGravity = a.getInteger(0, mGravity); int mColor = a.getColor(1, 0x33333333); a.recycle();// w w w.ja v a 2 s. c o m final Resources res = getResources(); mRidgeSize = res.getDimensionPixelSize(R.dimen.drag_grip_ridge_size); mRidgeGap = res.getDimensionPixelSize(R.dimen.drag_grip_ridge_gap); mRidgePaint = new Paint(); mRidgePaint.setColor(mColor); }
From source file:com.example.android.sampletvinput.presenter.CardPresenter.java
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { Video video = (Video) item;//w w w .jav a2s .c o m ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setTitleText(video.title); cardView.setContentText(video.studio); if (video.cardImageUrl != null) { // Set card size from dimension resources. Resources res = cardView.getResources(); int width = res.getDimensionPixelSize(R.dimen.card_width); int height = res.getDimensionPixelSize(R.dimen.card_height); cardView.setMainImageDimensions(width, height); Glide.with(cardView.getContext()).load(video.cardImageUrl).error(mDefaultCardImage) .diskCacheStrategy(NONE).into(cardView.getMainImageView()); //obnovit obrazek } }
From source file:im.ene.ribbon.TabletActionTabView.java
public TabletActionTabView(final BottomNavigationView parent, boolean expanded, final MenuParser.Menu menu) { super(parent, expanded, menu); this.evaluator = new ArgbEvaluator(); final Resources res = getResources(); this.iconSize = res.getDimensionPixelSize(R.dimen.ribbon_tablet_item_icon_size); this.animationDuration = menu.getItemAnimationDuration(); this.colorActive = menu.getColorActive(); this.colorInactive = menu.getColorInactive(); }
From source file:com.google.android.demos.jamendo.app.JamendoListActivity.java
protected final String getDimensionPixelSizeAsString(int resId) { Resources resources = getResources(); int size = resources.getDimensionPixelSize(resId); return String.valueOf(size); }
From source file:net.reichholf.dreamdroid.tv.presenter.CardPresenter.java
protected void bindSettingsViewHolder(Presenter.ViewHolder viewHolder, Object item) { ExtendedHashMap it = (ExtendedHashMap) item; ImageCardView cardView = (ImageCardView) viewHolder.view; cardView.setTitleText(it.getString("title")); Integer mainImageId = (int) it.get("icon"); if (mainImageId != null) cardView.setMainImage(cardView.getResources().getDrawable(mainImageId, null)); else/* w ww.j av a 2 s . c o m*/ cardView.setMainImage(mDefaultCardImage); cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER); Resources res = cardView.getResources(); int width = res.getDimensionPixelSize(R.dimen.card_width); int height = res.getDimensionPixelSize(R.dimen.card_height); cardView.setMainImageDimensions(width, height); }