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:fr.rolandl.smartshareactionprovider.SmartActivityChooserView.java

/**
 * Create a new instance.//  w w  w  .j  a  va  2 s . c o  m
 *
 * @param context  The application environment.
 * @param attrs    A collection of attributes.
 * @param defStyle The default style to apply to this view.
 */
public SmartActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.abc_activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content);
    mActivityChooserContentBackground = mActivityChooserContent.getBackground();

    mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button);
    mDefaultActivityButton.setOnClickListener(mCallbacks);
    mDefaultActivityButton.setOnLongClickListener(mCallbacks);
    mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image);

    mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.expand_activities_button);
    mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
    mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton.findViewById(R.id.image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}

From source file:com.example.FilteredActivityChooserView.java

/**
 * Create a new instance.//from   w w  w  .  j a v  a 2 s .  co m
 *
 * @param context The application environment.
 * @param attrs A collection of attributes.
 * @param defStyle The default style to apply to this view.
 */
public FilteredActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.abc_activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (LinearLayout) findViewById(R.id.activity_chooser_view_content);
    mActivityChooserContentBackground = mActivityChooserContent.getBackground();

    mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button);
    mDefaultActivityButton.setOnClickListener(mCallbacks);
    mDefaultActivityButton.setOnLongClickListener(mCallbacks);
    mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image);

    mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.expand_activities_button);
    mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
    mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton.findViewById(R.id.image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}

From source file:com.coinomi.wallet.ui.widget.ActivityChooserView.java

/**
 * Create a new instance./* w  w  w  . j  a  va  2 s  .c o m*/
 *
 * @param context The application environment.
 * @param attrs A collection of attributes.
 * @param defStyle The default style to apply to this view.
 */
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.abc_activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (LinearLayout) findViewById(R.id.activity_chooser_view_content);
    mActivityChooserContentBackground = mActivityChooserContent.getBackground();

    mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button);
    mDefaultActivityButton.setOnClickListener(mCallbacks);
    mDefaultActivityButton.setOnLongClickListener(mCallbacks);
    mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image);

    mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.expand_activities_button);
    mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
    mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton.findViewById(R.id.image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}

From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java

private void setupImageShow(Context context) {
    Resources res = context.getResources();
    mTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_text_size);
    mTextPadding = res.getDimensionPixelSize(R.dimen.photoeditor_text_padding);
    mOriginalTextMargin = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_margin);
    mOriginalTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_size);
    mBackgroundColor = res.getColor(R.color.background_screen);
    mOriginalText = res.getString(R.string.original_picture_text);
    mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
    setupGestureDetector(context);/*from   w  w  w.j a va2 s .  c om*/
    mActivity = (FilterShowActivity) context;
    if (sMask == null) {
        Bitmap mask = BitmapFactory.decodeResource(res, R.drawable.spot_mask);
        sMask = convertToAlphaMask(mask);
    }
    mEdgeEffect = new EdgeEffectCompat(context);
    mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Resources res = getResources();
    if (getArguments() != null) {
        mCurrentMode = getArguments().getInt(TomahawkFragment.CONTENT_HEADER_MODE, -1);

        switch (mCurrentMode) {
        case MODE_HEADER_DYNAMIC:
            mHeaderScrollableHeight = res.getDimensionPixelSize(R.dimen.header_clear_space_scrollable);
            mHeaderNonscrollableHeight = res.getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable);
            break;
        case MODE_HEADER_DYNAMIC_PAGER:
            mHeaderScrollableHeight = res.getDimensionPixelSize(R.dimen.header_clear_space_scrollable);
            mHeaderNonscrollableHeight = res.getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable)
                    + res.getDimensionPixelSize(R.dimen.pager_indicator_height);
            break;
        case MODE_HEADER_STATIC:
            mHeaderNonscrollableHeight = res
                    .getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable_static);
            break;
        case MODE_HEADER_STATIC_USER:
            mHeaderNonscrollableHeight = res
                    .getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable_static_user);
            break;
        case MODE_HEADER_STATIC_SMALL:
            mHeaderNonscrollableHeight = res
                    .getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material)
                    + res.getDimensionPixelSize(R.dimen.pager_indicator_height);
            break;
        case MODE_HEADER_STATIC_CHARTS:
            mHeaderNonscrollableHeight = res.getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable);
            break;
        case MODE_ACTIONBAR_FILLED:
            mHeaderNonscrollableHeight = res
                    .getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
            break;
        case MODE_HEADER_PLAYBACK:
            mHeaderNonscrollableHeight = res
                    .getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable_playback);
            break;
        case MODE_HEADER_NONE:
            break;
        case MODE_MYLOCALPLAYLIST:
            break;
        default:/*w  ww. jav a2  s.  c o  m*/
            throw new RuntimeException("Missing or invalid ContentHeaderFragment mode");
        }
        if (getArguments().containsKey(TomahawkFragment.CONTAINER_FRAGMENT_ID)) {
            mContainerFragmentId = getArguments().getLong(TomahawkFragment.CONTAINER_FRAGMENT_ID);
        }
        if (getArguments().containsKey(TomahawkFragment.CONTAINER_FRAGMENT_PAGE)) {
            mContainerFragmentPage = getArguments().getInt(TomahawkFragment.CONTAINER_FRAGMENT_PAGE);
        }
    }

    if (getMediaController() != null) {
        String playbackManagerId = getMediaController().getExtras()
                .getString(PlaybackService.EXTRAS_KEY_PLAYBACKMANAGER);
        mPlaybackManager = PlaybackManager.getByKey(playbackManagerId);
    }
}

From source file:com.actionbarsherlock.widget.ActivityChooserView.java

/**
 * Create a new instance./*from www.java  2 s. c  o  m*/
 *
 * @param context The application environment.
 * @param attrs A collection of attributes.
 * @param defStyle The default style to apply to this view.
 */
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext = context;

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.SherlockActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.SherlockActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.SherlockActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(mContext);
    inflater.inflate(R.layout.abs__activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (IcsLinearLayout) findViewById(R.id.abs__activity_chooser_view_content);
    mActivityChooserContentBackground = mActivityChooserContent.getBackground();

    mDefaultActivityButton = (FrameLayout) findViewById(R.id.abs__default_activity_button);
    mDefaultActivityButton.setOnClickListener(mCallbacks);
    mDefaultActivityButton.setOnLongClickListener(mCallbacks);
    mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.abs__image);

    mExpandActivityOverflowButton = (FrameLayout) findViewById(R.id.abs__expand_activities_button);
    mExpandActivityOverflowButton.setOnClickListener(mCallbacks);
    mExpandActivityOverflowButtonImage = (ImageView) mExpandActivityOverflowButton
            .findViewById(R.id.abs__image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abs__config_prefDialogWidth));
}

From source file:org.solovyev.android.calculator.widget.CalculatorWidget.java

@TargetApi(JELLY_BEAN)
private int getLayoutJellyBean(@Nonnull AppWidgetManager manager, int widgetId, Resources resources,
        @Nonnull SimpleTheme theme) {/*from   w  ww .  j a  v a  2s. c o  m*/
    final Bundle options = manager.getAppWidgetOptions(widgetId);
    if (options == null) {
        return getDefaultLayout(theme);
    }

    final int category = options.getInt(OPTION_APPWIDGET_HOST_CATEGORY, -1);
    if (category == -1) {
        return getDefaultLayout(theme);
    }

    final boolean keyguard = category == WIDGET_CATEGORY_KEYGUARD;
    if (!keyguard) {
        return getDefaultLayout(theme);
    }

    final int widgetMinHeight = App.toPixels(resources.getDisplayMetrics(),
            options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, 0));
    final int lockScreenMinHeight = resources.getDimensionPixelSize(R.dimen.min_expanded_height_lock_screen);
    final boolean expanded = widgetMinHeight >= lockScreenMinHeight;
    if (expanded) {
        return R.layout.widget_layout_lockscreen;
    } else {
        return R.layout.widget_layout_lockscreen_collapsed;
    }
}

From source file:android.support.v7.internal.widget.ActivityChooserView.java

/**
 * Create a new instance.//from  w w  w  .j av  a 2  s .c  om
 *
 * @param context The application environment.
 * @param attrs A collection of attributes.
 * @param defStyle The default style to apply to this view.
 */
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView,
            defStyle, 0);

    mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount,
            ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT);

    Drawable expandActivityOverflowButtonDrawable = attributesArray
            .getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);

    attributesArray.recycle();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(R.layout.abc_activity_chooser_view, this, true);

    mCallbacks = new Callbacks();

    mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content);
    mActivityChooserContentBackground = mActivityChooserContent.getBackground();

    mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button);
    mDefaultActivityButton.setOnClickListener(mCallbacks);
    mDefaultActivityButton.setOnLongClickListener(mCallbacks);
    mDefaultActivityButtonImage = (ImageView) mDefaultActivityButton.findViewById(R.id.image);

    final FrameLayout expandButton = (FrameLayout) findViewById(R.id.expand_activities_button);
    expandButton.setOnClickListener(mCallbacks);
    expandButton.setOnTouchListener(new ListPopupWindow.ForwardingListener(expandButton) {
        @Override
        public ListPopupWindow getPopup() {
            return getListPopupWindow();
        }

        @Override
        protected boolean onForwardingStarted() {
            showPopup();
            return true;
        }

        @Override
        protected boolean onForwardingStopped() {
            dismissPopup();
            return true;
        }
    });
    mExpandActivityOverflowButton = expandButton;
    mExpandActivityOverflowButtonImage = (ImageView) expandButton.findViewById(R.id.image);
    mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);

    mAdapter = new ActivityChooserViewAdapter();
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            updateAppearance();
        }
    });

    Resources resources = context.getResources();
    mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
            resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}

From source file:pl.motyczko.scrollheader.CarouselContainer.java

/**
 * @param context The {@link Context} to use
 * @param attrs The attributes of the XML tag that is inflating the view
 *///from ww w .  j a  v  a2 s. c  o  m
public CarouselContainer(Context context, AttributeSet attrs) {
    super(context, attrs);
    // Add the onTouchListener
    setOnTouchListener(this);
    // Retrieve the carousel dimensions
    final Resources res = getResources();
    // Width of the tab
    mTabWidthScreenFraction = res.getFraction(R.fraction.tab_width_screen_percentage, 1, 1);
    // Height of the tab
    mTabHeightScreenFraction = res.getFraction(R.fraction.tab_height_screen_percentage, 1, 1);
    // Height of the label
    mTabDisplayLabelHeight = res.getDimensionPixelSize(R.dimen.carousel_label_height);
    // Height of the image shadow
    mTabShadowHeight = res.getDimensionPixelSize(R.dimen.carousel_image_shadow_height);
    LayoutInflater.from(getContext()).inflate(R.layout.carousel_content, this, true);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CarouselContainer);
    mMinHeight = a.getDimensionPixelSize(R.styleable.CarouselContainer_android_minHeight, mMinHeight);
    a.recycle();

}

From source file:io.doist.datetimepicker.date.SimpleMonthView.java

public SimpleMonthView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final Resources res = context.getResources();
    mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.sans_serif);

    mStringBuilder = new StringBuilder(50);
    mFormatter = new Formatter(mStringBuilder, Locale.getDefault());

    mMiniDayNumberTextSize = res.getDimensionPixelSize(R.dimen.datepicker_day_number_size);
    mMonthLabelTextSize = res.getDimensionPixelSize(R.dimen.datepicker_month_label_size);
    mMonthDayLabelTextSize = res.getDimensionPixelSize(R.dimen.datepicker_month_day_label_text_size);
    mMonthHeaderSize = res.getDimensionPixelOffset(R.dimen.datepicker_month_list_item_header_height);
    mDaySelectedCircleSize = res.getDimensionPixelSize(R.dimen.datepicker_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.datepicker_view_animator_height) - mMonthHeaderSize)
            / MAX_NUM_ROWS;//from  ww  w.j  a  v a  2s  .  c  o m

    // Set up accessibility components.
    mTouchHelper = new MonthViewTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, IMPORTANT_FOR_ACCESSIBILITY_YES);
    mLockAccessibilityDelegate = true;

    // Sets up any standard paints that will be used
    initView();
}