Example usage for android.content.res Resources getDimensionPixelOffset

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

Introduction

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

Prototype

public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException 

Source Link

Document

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

Usage

From source file:opt.android.datetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr) {
    super(context, attr);
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.sans_serif);

    mDayTextColor = res.getColor(R.color.opt_dtpicker_date_picker_text_normal);
    mTodayNumberColor = res.getColor(R.color.opt_dtpicker_blue);
    mDisabledDayTextColor = res.getColor(R.color.opt_dtpicker_date_picker_text_disabled);
    mMonthTitleColor = res.getColor(R.color.opt_dtpicker_white);
    //        mMonthTitleBGColor = res.getColor(R.color.circle_background);

    // kman/*from w  w w  .j a v a2  s  . c  o m*/
    final TypedArray a = context.obtainStyledAttributes(Utils.COLOR_ATTRS);
    final ColorStateList colorPrimary = a.getColorStateList(0);
    final ColorStateList colorSecondary = a.getColorStateList(1);
    a.recycle();

    mMonthTitleColor = colorPrimary.getColorForState(ENABLED_STATE_SET, colorPrimary.getDefaultColor());
    mDayTextColor = colorSecondary.getColorForState(ENABLED_STATE_SET, colorSecondary.getDefaultColor());
    mDisabledDayTextColor = colorSecondary.getColorForState(Utils.DISABLED_STATE_SET, mDayTextColor);

    final boolean isDarkTheme = Utils.isThemeDark(mMonthTitleColor);
    if (isDarkTheme) {
        mTodayNumberColor = res.getColor(R.color.opt_dtpicker_blue_dark);
    }
    // kman end

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

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.opt_dtpicker_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.opt_dtpicker_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.opt_dtpicker_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.opt_dtpicker_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.opt_dtpicker_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.opt_dtpicker_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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

From source file:com.jarklee.materialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;// w w  w  .  ja va2s . co m
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle,
        final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews,
        final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;//from   w  w  w.  ja  v a  2 s .com
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle,
            R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height);
}

From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripLayoutHelper.java

public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle,
        final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews,
        final ArrayList<TextView> debugInfoViews) {

    mWordViews = wordViews;//from w  w w.j av  a2  s . co  m
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;
    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle,
            R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height);
}

From source file:com.layernet.thaidatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;//  w  w w .  j  a  v a 2s . c o  m
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

    mStringBuilder = new StringBuilder(50);
    mFormatter = new Formatter(mStringBuilder, locale);

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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

From source file:com.borax12.materialdaterangepicker.single.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;/*ww w . j  a v a  2  s  . c o m*/
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

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

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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

From source file:com.andexert.calendarlistview.library.SimpleMonthView.java

public SimpleMonthView(Context context, TypedArray typedArray) {
    super(context);

    Resources resources = context.getResources();
    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();
    today = new Time(Time.getCurrentTimezone());
    today.setToNow();//from w  w  w .  ja  v  a2  s  .c  om
    mDayOfWeekTypeface = resources.getString(R.string.sans_serif);
    mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay,
            resources.getColor(R.color.to_day));
    mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName,
            resources.getColor(R.color.normal_day));
    mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName,
            resources.getColor(R.color.normal_day));
    mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDay,
            resources.getColor(R.color.normal_day));
    mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDay,
            resources.getColor(R.color.normal_day));
    mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground,
            resources.getColor(R.color.selected_day_background));
    mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText,
            resources.getColor(R.color.selected_day_text));
    mIsShowMonthDay = typedArray.getBoolean(R.styleable.DayPickerView_showMonthDay, true);
    mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay,
            resources.getDimensionPixelSize(R.dimen.text_size_day));
    MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeMonth,
            resources.getDimensionPixelSize(R.dimen.text_size_month));
    MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDayName,
            resources.getDimensionPixelSize(R.dimen.text_size_day_name));
    MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight,
            resources.getDimensionPixelOffset(
                    mIsShowMonthDay ? R.dimen.header_month_height_showWeek : R.dimen.header_month_height));
    DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius,
            resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

    mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight,
            resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6);

    isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, true);

    initView();

}

From source file:com.udmurtlyk.extrainputmethod.latin.suggestions.SuggestionStripLayoutHelper.java

public SuggestionStripLayoutHelper(final Context context, final AttributeSet attrs, final int defStyle,
        final ArrayList<TextView> wordViews, final ArrayList<View> dividerViews,
        final ArrayList<TextView> debugInfoViews) {
    mWordViews = wordViews;/*from   ww w.  ja  va  2  s  .  c  o m*/
    mDividerViews = dividerViews;
    mDebugInfoViews = debugInfoViews;

    final TextView wordView = wordViews.get(0);
    final View dividerView = dividerViews.get(0);
    mPadding = wordView.getCompoundPaddingLeft() + wordView.getCompoundPaddingRight();
    dividerView.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mDividerWidth = dividerView.getMeasuredWidth();

    final Resources res = wordView.getResources();
    mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SuggestionStripView, defStyle,
            R.style.SuggestionStripView);
    mSuggestionStripOptions = a.getInt(R.styleable.SuggestionStripView_suggestionStripOptions, 0);
    mAlphaObsoleted = ResourceUtils.getFraction(a, R.styleable.SuggestionStripView_alphaObsoleted, 1.0f);
    mColorValidTypedWord = a.getColor(R.styleable.SuggestionStripView_colorValidTypedWord, 0);
    mColorTypedWord = a.getColor(R.styleable.SuggestionStripView_colorTypedWord, 0);
    mColorAutoCorrect = a.getColor(R.styleable.SuggestionStripView_colorAutoCorrect, 0);
    mColorSuggested = a.getColor(R.styleable.SuggestionStripView_colorSuggested, 0);
    mColorShortcut = a.getColor(R.styleable.SuggestionStripView_colorShortcut, 0);
    mSuggestionsCountInStrip = a.getInt(R.styleable.SuggestionStripView_suggestionsCountInStrip,
            DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
    mCenterSuggestionWeight = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_centerSuggestionPercentile, DEFAULT_CENTER_SUGGESTION_PERCENTILE);
    mMaxMoreSuggestionsRow = a.getInt(R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
            DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
    mMinMoreSuggestionsWidth = ResourceUtils.getFraction(a,
            R.styleable.SuggestionStripView_minMoreSuggestionsWidth, 1.0f);
    a.recycle();

    mMoreSuggestionsHint = getMoreSuggestionsHint(res,
            res.getDimension(R.dimen.config_more_suggestions_hint_text_size), mColorAutoCorrect);
    mCenterPositionInStrip = mSuggestionsCountInStrip / 2;
    // Assuming there are at least three suggestions. Also, note that the suggestions are
    // laid out according to script direction, so this is left of the center for LTR scripts
    // and right of the center for RTL scripts.
    mTypedWordPositionWhenAutocorrect = mCenterPositionInStrip - 1;
    mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(R.dimen.config_more_suggestions_bottom_gap);
    mMoreSuggestionsRowHeight = res.getDimensionPixelSize(R.dimen.config_more_suggestions_row_height);
}

From source file:com.wdullaer.materialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;/*from  w  w  w.  j  a  v  a 2 s  .co m*/
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance(mController.getTimeZone());
    mCalendar = Calendar.getInstance(mController.getTimeZone());

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

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

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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

From source file:com.mojtaba.materialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;/*from  w w  w  .ja  va 2s  . c  o  m*/
    Resources res = context.getResources();

    mDayLabelCalendar = new PersianCalendar();
    mPersianCalendar = new PersianCalendar();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

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

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

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

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