List of usage examples for android.content.res Resources getDimensionPixelSize
public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException
From source file:android.support.v7.internal.view.ActionBarPolicy.java
public int getTabContainerHeight() { TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0); int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0); Resources r = mContext.getResources(); if (!hasEmbeddedTabs()) { // Stacked tabs; limit the height height = Math.min(height, r.getDimensionPixelSize(R.dimen.abc_action_bar_stacked_max_height)); }//from w w w .j av a 2 s. co m a.recycle(); return height; }
From source file:is.hello.go99.example.view.InfoTooltipView.java
/** * Shows the tooltip above a given view within a given parent view. * * @param parent The parent view to attach the tooltip to. * @param aboveView The view to display the tooltip above. * @param onDismissListener A functor to call if the tooltip is dismissed without user intervention. *///w w w . j a v a 2 s . co m public void showAboveView(final @NonNull ViewGroup parent, final @NonNull View aboveView, final @NonNull OnDismissListener onDismissListener) { text.setVisibility(INVISIBLE); parent.addView(this, new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); final Resources resources = getResources(); final int overlap = resources.getDimensionPixelSize(R.dimen.view_info_tooltip_overlap); final LayoutParams layoutParams = (LayoutParams) text.getLayoutParams(); layoutParams.bottomMargin = (parent.getHeight() - aboveView.getTop()) - overlap; layoutParams.leftMargin = aboveView.getLeft(); text.requestLayout(); post(new Runnable() { @Override public void run() { animateInText(onDismissListener); } }); }
From source file:android.support.v7ox.view.ActionBarPolicy.java
public int getTabContainerHeight() { TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle_ox, 0); int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0); Resources r = mContext.getResources(); if (!hasEmbeddedTabs()) { // Stacked tabs; limit the height height = Math.min(height, r.getDimensionPixelSize(R.dimen.abc_action_bar_stacked_max_height)); }/*from w w w . j av a 2 s.c o m*/ a.recycle(); return height; }
From source file:com.hgdendi.contactslist.common.FloatingBarItemDecoration.java
public FloatingBarItemDecoration(Context context, Map<Integer, String> list) { this.mContext = context; Resources resources = mContext.getResources(); this.mList = list; this.mTitleHeight = resources.getDimensionPixelSize(R.dimen.item_decoration_title_height); mBackgroundPaint = new Paint(); mBackgroundPaint.setColor(ContextCompat.getColor(mContext, R.color.item_decoration_title_background)); mTextPaint = new Paint(); mTextPaint.setColor(ContextCompat.getColor(mContext, R.color.item_decoration_title_fontcolor)); mTextPaint// w w w .j a v a 2 s . c o m .setTextSize(mContext.getResources().getDimensionPixelSize(R.dimen.item_decoration_title_fontsize)); Paint.FontMetrics fm = mTextPaint.getFontMetrics(); mTextHeight = (int) (fm.bottom - fm.top); mTextBaselineOffset = (int) fm.bottom; mTextStartMargin = resources.getDimensionPixelOffset(R.dimen.item_decoration_title_start_margin); }
From source file:com.android.messaging.datamodel.BugleNotifications.java
private static void checkInitialized() { if (!sInitialized) { final Resources resources = Factory.get().getApplicationContext().getResources(); sWearableImageWidth = resources.getDimensionPixelSize(R.dimen.notification_wearable_image_width); sWearableImageHeight = resources.getDimensionPixelSize(R.dimen.notification_wearable_image_height); sIconHeight = (int) resources.getDimension(android.R.dimen.notification_large_icon_height); sIconWidth = (int) resources.getDimension(android.R.dimen.notification_large_icon_width); sInitialized = true;//from w w w. j a v a 2 s. c om } }
From source file:is.hello.go99.example.view.InfoTooltipView.java
@SuppressWarnings("deprecation") public InfoTooltipView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.text = new TextView(context); text.setTextAppearance(context, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Body2); text.setBackgroundResource(R.drawable.background_info_tooltip); final Resources resources = getResources(); final int paddingHorizontal = resources.getDimensionPixelSize(R.dimen.view_info_tooltip_padding_horizontal), paddingVertical = resources.getDimensionPixelSize(R.dimen.view_info_tooltip_padding_vertical); text.setPadding(text.getPaddingLeft() + paddingHorizontal, text.getPaddingTop() + paddingVertical, text.getPaddingRight() + paddingHorizontal, text.getPaddingBottom() + paddingVertical); @SuppressLint("RtlHardcoded") final LayoutParams textLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT); addView(text, textLayoutParams);//from w w w . j a v a 2s . co m }
From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.DistanceDialogFragment.java
@SuppressLint("InflateParams") @Override/*from w w w.ja v a2s . co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Context ctx = getCompatContext(); AlertDialog dialog = new AlertDialog.Builder(ctx) .setTitle(getResources().getString(R.string.careerstack_dialog_distance_title)) .setPositiveButton(android.R.string.ok, this).setNegativeButton(android.R.string.cancel, this) .create(); //create basic dialog //insert custom views View content = View.inflate(ctx, R.layout.viewstub_distance_seekbar, null); initViews(content); //preload views Resources r = getResources(); content.setPadding(r.getDimensionPixelSize(R.dimen.dialog_margins), r.getDimensionPixelSize(R.dimen.dialog_margins), r.getDimensionPixelSize(R.dimen.dialog_margins), r.getDimensionPixelSize(R.dimen.dialog_margins)); dialog.setView(content); onValueUpdate(currentDistanceValue); return dialog; }
From source file:com.google.android.demos.jamendo.app.AlbumGalleryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.jamendo_gallery); mGallery = (Gallery) findViewById(android.R.id.list); mTextAlbumName = (TextView) findViewById(R.id.text1); mTextArtistName = (TextView) findViewById(R.id.text2); mTextAlbumGenre = (TextView) findViewById(R.id.text3); Resources resources = getResources(); mImageSize = resources.getDimensionPixelSize(R.dimen.gallery_size); AlbumDetailsObserver albumDetailsObserver = new AlbumDetailsObserver(); mAdapter = new AlbumGalleryAdapter(this); mAdapter.registerDataSetObserver(albumDetailsObserver); mAlbums = new Loadable(getSupportLoaderManager(), LOADER_ALBUMS, new StatusViewManager(this, LOADER_ALBUMS, this, this)); mGallery.setAdapter(new GalleryDecorator(mAdapter, this)); mGallery.setOnItemClickListener(this); mGallery.setOnItemSelectedListener(new CompositeOnItemSelectedListener(albumDetailsObserver, mAdapter, new GalleryScrollListener(mAlbums))); mAlbums.init();/* w ww. j a v a 2 s . c o m*/ }
From source file:com.google.android.demos.jamendo.app.ArtistGalleryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.jamendo_gallery); mGallery = (Gallery) findViewById(android.R.id.list); mTextArtistName = (TextView) findViewById(R.id.text1); mTextArtistGenre = (TextView) findViewById(R.id.text2); Resources resources = getResources(); mImageSize = resources.getDimensionPixelSize(R.dimen.gallery_size); ArtistDetailsObserver artistDetailsObserver = new ArtistDetailsObserver(); mAdapter = new ArtistGalleryAdapter(this); mAdapter.registerDataSetObserver(artistDetailsObserver); mArtists = new Loadable(getSupportLoaderManager(), LOADER_ARTISTS, new StatusViewManager(this, LOADER_ARTISTS, this, this)); mGallery.setAdapter(new GalleryDecorator(mAdapter, this)); mGallery.setOnItemClickListener(this); mGallery.setOnItemSelectedListener(new CompositeOnItemSelectedListener(artistDetailsObserver, mAdapter, new GalleryScrollListener(mArtists))); mArtists.init();/*from w w w. j av a2 s.co m*/ }
From source file:com.iopixel.watchface.wear.app.main.grid.WatchfaceGridFragment.java
@Nullable @Override/* w ww .ja v a2s. c o m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mBinding = DataBindingUtil.inflate(inflater, R.layout.watchface_grid, container, false); mBinding.rclGrid.setHasFixedSize(true); mLayoutManager = new GridLayoutManager(getContext(), 1); mBinding.rclGrid.setLayoutManager(mLayoutManager); // Calculate the optimal column count based on the width of the grid, and the width of one cell mBinding.rclGrid.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { Resources resources = v.getContext().getResources(); int cellWidth = resources.getDimensionPixelSize(R.dimen.watchface_grid_item_preview_width) + resources.getDimensionPixelSize(R.dimen.watchface_grid_item_padding) * 2; // We also want some minimum padding between cells int interPadding = resources.getDimensionPixelSize(R.dimen.watchface_grid_item_inter_padding); cellWidth += interPadding; int gridWidth = right - left; gridWidth -= interPadding; int columnCount = gridWidth / cellWidth; mLayoutManager.setSpanCount(columnCount); // Relayout everything since we changed the number of columns if (mAdapter != null) mAdapter.notifyDataSetChanged(); // We're done mBinding.rclGrid.removeOnLayoutChangeListener(this); } }); return mBinding.getRoot(); }