Example usage for android.content.res Resources getDimensionPixelSize

List of usage examples for android.content.res Resources getDimensionPixelSize

Introduction

In this page you can find the example usage for android.content.res Resources getDimensionPixelSize.

Prototype

public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

Usage

From source file:com.sefford.material.sample.contacts.list.ui.renderers.ContactRenderer.java

public ContactRenderer(Resources resources, View view) {
    super(view);//from   w w  w.  j av  a 2s .  com
    ButterKnife.inject(this, view);
    // This change will turn the rounded border into a circular avatar
    this.transformation = new RoundedBorderTransformation(resources.getDimensionPixelSize(R.dimen.avatar_size));
    picasso = Picasso.with(view.getContext());
    placeholder = new LetterTileDrawable(view.getResources(),
            view.getResources().getDimensionPixelSize(R.dimen.avatar_rounded_corners));
    this.resources = resources;
}

From source file:im.ene.ribbon.FixedActionTabView.java

public FixedActionTabView(final BottomNavigationView parent, boolean expanded, final MenuParser.Menu menu) {
    super(parent, expanded, menu);

    final Resources res = getResources();
    this.paddingTopActive = res.getDimensionPixelSize(R.dimen.ribbon_fixed_active_item_padding_top);
    this.paddingTopInactive = res.getDimensionPixelSize(R.dimen.ribbon_fixed_inactive_item_padding_top);
    this.paddingBottom = res.getDimensionPixelSize(R.dimen.ribbon_fixed_item_padding_bottom);
    this.paddingHorizontal = res.getDimensionPixelSize(R.dimen.ribbon_fixed_item_padding_horizontal);
    this.textSizeInactive = res.getDimensionPixelSize(R.dimen.ribbon_fixed_inactive_item_text_size);
    this.iconSize = res.getDimensionPixelSize(R.dimen.ribbon_fixed_item_icon_size);

    this.animationDuration = menu.getItemAnimationDuration();
    this.colorActive = menu.getColorActive();
    this.colorInactive = menu.getColorInactive();
    this.centerY = paddingTopActive;
    this.canvasTextScale = expanded ? TEXT_SCALE_ACTIVE : 1f;
    this.iconTranslation = expanded ? 0 : (paddingTopInactive - paddingTopActive);

    log(TAG, DEBUG, "colors: %x, %x", colorInactive, colorActive);

    this.textPaint.setColor(Color.WHITE);
    this.textPaint.setHinting(Paint.HINTING_ON);
    this.textPaint.setLinearText(true);
    this.textPaint.setSubpixelText(true);
    this.textPaint.setTextSize(textSizeInactive);
    this.textPaint.setColor(expanded ? colorActive : colorInactive);
}

From source file:com.finchuk.clock2.timers.ui.TimersFragment.java

@Nullable
@Override/*from  w ww . j  a v a  2s  .c  om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    final Resources r = getResources();
    if (getOrientation(r) == Configuration.ORIENTATION_LANDSCAPE) {
        RecyclerView list = findById(view, R.id.list);
        int cardViewMargin = r.getDimensionPixelSize(R.dimen.cardview_margin);
        list.setPaddingRelative(cardViewMargin/*start*/, cardViewMargin/*top*/, 0, list.getPaddingBottom());
    }
    return view;
}

From source file:cn.jay.widget.BottomNavigationMenuView.java

public BottomNavigationMenuView(Context context, AttributeSet attrs) {
    super(context, attrs);
    final Resources res = getResources();
    mInactiveItemMaxWidth = res
            .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_item_max_width);
    mInactiveItemMinWidth = res/* w w  w . ja  v a2s .  co  m*/
            .getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_item_min_width);
    mActiveItemMaxWidth = res.getDimensionPixelSize(
            android.support.design.R.dimen.design_bottom_navigation_active_item_max_width);
    mItemHeight = res.getDimensionPixelSize(android.support.design.R.dimen.design_bottom_navigation_height);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mAnimationHelper = new BottomNavigationAnimationHelperIcs();
    } else {
        mAnimationHelper = new BottomNavigationAnimationHelperBase();
    }

    mOnClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            final BottomNavigationItemView itemView = (BottomNavigationItemView) v;
            final int itemPosition = itemView.getItemPosition();
            activateNewButton(itemPosition);
            mMenu.performItemAction(itemView.getItemData(), mPresenter, 0);
        }
    };
}

From source file:net.yanzm.mth.MaterialTabHost.java

public MaterialTabHost(Context context, AttributeSet attrs) {
    super(context, attrs);

    inflater = LayoutInflater.from(context);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialTabHost, 0, 0);
    int indicatorColor = a.getColor(R.styleable.MaterialTabHost_colorTabIndicator, Color.YELLOW);
    colorControlActivated = a.getColor(R.styleable.MaterialTabHost_colorBackground, Color.WHITE);

    setBackgroundColor(colorControlActivated);
    a.recycle();/*  w  ww.ja  va2 s .  com*/

    // ColorDrawable on 2.x does not use getBounds() so use ShapeDrawable
    indicator = new ShapeDrawable();
    indicator.setColorFilter(indicatorColor, PorterDuff.Mode.SRC_ATOP);

    Resources res = context.getResources();
    indicatorHeight = res.getDimensionPixelSize(R.dimen.mth_tab_indicator_height);
    leftOffset = res.getDimensionPixelSize(R.dimen.mth_tab_left_offset);
    int tabHeight = res.getDimensionPixelSize(R.dimen.mth_tab_height);

    tabWidget = new TabWidget(context);
    tabWidget.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, tabHeight));
    tabWidget.setId(android.R.id.tabs);
    tabWidget.setStripEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        tabWidget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    }
    addView(tabWidget);

    FrameLayout fl = new FrameLayout(context);
    fl.setLayoutParams(new LayoutParams(0, 0));
    fl.setId(android.R.id.tabcontent);
    addView(fl);

    setup();

    setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            if (listener != null) {
                listener.onTabSelected(Integer.valueOf(tabId));
            }
        }
    });

    float density = getResources().getDisplayMetrics().density;

    // set elevation for App bar
    // http://www.google.com/design/spec/what-is-material/objects-in-3d-space.html#objects-in-3d-space-elevation
    ViewCompat.setElevation(this, APP_TAB_ELEVATION * density);
}

From source file:comkriscamillerimobilehci.httpsgithub.cardcutter.SimpleGridPagerAdapter.java

private Fragment cardFragment(int titleRes, int textRes) {
    Resources res = mContext.getResources();
    CardFragment fragment = CardFragment.create(res.getText(titleRes), res.getText(textRes));
    // Add some extra bottom margin to leave room for the page indicator
    fragment.setCardMarginBottom(res.getDimensionPixelSize(R.dimen.card_content_padding_rect_top));
    return fragment;
}

From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java

private int getNavBarDimen(String resourceString) {
    Resources r = getResources();
    int id = r.getIdentifier(resourceString, "dimen", "android");
    if (id > 0) {
        return r.getDimensionPixelSize(id);
    } else {//from   w  w w.  ja  v a2  s .  c om
        return 0;
    }
}

From source file:android.support.design.internal.BottomNavigationMenuView.java

public BottomNavigationMenuView(Context context, AttributeSet attrs) {
    super(context, attrs);
    final Resources res = getResources();
    mInactiveItemMaxWidth = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_max_width);
    mInactiveItemMinWidth = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_item_min_width);
    mActiveItemMaxWidth = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_item_max_width);
    mItemHeight = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_height);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mAnimationHelper = new BottomNavigationAnimationHelperIcs();
    } else {//w  ww.j av  a 2  s . c om
        mAnimationHelper = new BottomNavigationAnimationHelperBase();
    }

    mOnClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            final BottomNavigationItemView itemView = (BottomNavigationItemView) v;
            MenuItem item = itemView.getItemData();
            if (!mMenu.performItemAction(item, mPresenter, 0)) {
                item.setChecked(true);
            }
        }
    };
    mTempChildWidths = new int[BottomNavigationMenu.MAX_ITEM_COUNT];
}

From source file:com.syncedsynapse.kore2.ui.AddonDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    addonId = getArguments().getString(ADDONID, null);

    if ((container == null) || (addonId == null)) {
        // We're not being shown or there's nothing to show
        return null;
    }//from   ww w  . ja v  a2s  .  com

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_addon_details, container, false);
    ButterKnife.inject(this, root);

    hostManager = HostManager.getInstance(getActivity());
    hostInfo = hostManager.getHostInfo();

    // Setup dim the fanart when scroll changes. Full dim on 4 * iconSize dp
    Resources resources = getActivity().getResources();
    final int pixelsToTransparent = 4 * resources.getDimensionPixelSize(R.dimen.default_icon_size);
    mediaPanel.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            float y = mediaPanel.getScrollY();
            float newAlpha = Math.min(1, Math.max(0, 1 - (y / pixelsToTransparent)));
            mediaArt.setAlpha(newAlpha);
        }
    });

    FloatingActionButton fab = (FloatingActionButton) fabButton;
    fab.attachToScrollView((ObservableScrollView) mediaPanel);

    // Pad main content view to overlap with bottom system bar
    //        UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true);
    //        mediaPanel.setClipToPadding(false);

    return root;
}

From source file:com.xycode.xylibrary.uiKit.recyclerview.FloatingBarItemDecoration.java

public FloatingBarItemDecoration(Context context, List sourceList, Options options,
        ITitleTextGetter iTitleTextGetter) {
    this.mContext = context;
    Resources resources = mContext.getResources();
    this.iTitleTextGetter = iTitleTextGetter;
    this.headerList = preHeaderList(sourceList);
    this.mTitleHeight = resources.getDimensionPixelSize(options.titleHeight);

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(ContextCompat.getColor(mContext, options.backgroundColorRes));

    mTextPaint = new Paint();
    mTextPaint.setColor(ContextCompat.getColor(mContext, options.textColor));
    mTextPaint.setTextSize(mContext.getResources().getDimensionPixelSize(options.textSize));

    Paint.FontMetrics fm = mTextPaint.getFontMetrics();
    mTextHeight = (int) (fm.bottom - fm.top);
    mTextBaselineOffset = (int) fm.bottom;
    mTextStartMargin = resources.getDimensionPixelOffset(options.textStartMargin);
}