Example usage for android.content.res TypedArray getFloat

List of usage examples for android.content.res TypedArray getFloat

Introduction

In this page you can find the example usage for android.content.res TypedArray getFloat.

Prototype

public float getFloat(@StyleableRes int index, float defValue) 

Source Link

Document

Retrieve the float value for the attribute at index.

Usage

From source file:ru.shmakinv.android.material.widget.CollapsingTextHelper.java

@SuppressLint("PrivateResource")
public void setCollapsedTextAppearance(int resId) {
    TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
        mCollapsedTextColor = a.getColor(R.styleable.TextAppearance_android_textColor, mCollapsedTextColor);
    }/*from w w  w.j a v a  2 s.c o m*/
    if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
        mCollapsedTextSize = a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
                (int) mCollapsedTextSize);
    }
    mCollapsedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
    mCollapsedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
    mCollapsedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
    mCollapsedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
    a.recycle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mCollapsedTypeface = readFontFamilyTypeface(resId);
    }

    recalculate();
}

From source file:com.commonsware.cwac.crossport.design.widget.CollapsingTextHelper.java

void setExpandedTextAppearance(int resId) {
    TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
        mExpandedTextColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor);
    }// w  ww . j a v a2  s . c o m
    if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
        mExpandedTextSize = a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
                (int) mExpandedTextSize);
    }
    mExpandedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
    mExpandedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
    mExpandedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
    mExpandedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
    a.recycle();

    if (Build.VERSION.SDK_INT >= 16) {
        mExpandedTypeface = readFontFamilyTypeface(resId);
    }

    recalculate();
}

From source file:com.commonsware.cwac.crossport.design.widget.CollapsingTextHelper.java

void setCollapsedTextAppearance(int resId) {
    TypedArray a = mView.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance);
    if (a.hasValue(R.styleable.TextAppearance_android_textColor)) {
        mCollapsedTextColor = a.getColorStateList(R.styleable.TextAppearance_android_textColor);
    }// www .j  a  v a  2 s  . com
    if (a.hasValue(R.styleable.TextAppearance_android_textSize)) {
        mCollapsedTextSize = a.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize,
                (int) mCollapsedTextSize);
    }
    mCollapsedShadowColor = a.getInt(R.styleable.TextAppearance_android_shadowColor, 0);
    mCollapsedShadowDx = a.getFloat(R.styleable.TextAppearance_android_shadowDx, 0);
    mCollapsedShadowDy = a.getFloat(R.styleable.TextAppearance_android_shadowDy, 0);
    mCollapsedShadowRadius = a.getFloat(R.styleable.TextAppearance_android_shadowRadius, 0);
    a.recycle();

    if (Build.VERSION.SDK_INT >= 16) {
        mCollapsedTypeface = readFontFamilyTypeface(resId);
    }

    recalculate();
}

From source file:com.shawnway.nav.app.wtw.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);//from   www . ja  v a2  s.com
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tabsContainer.setGravity(Gravity.CENTER);
    if (shouldExpand) {
        tabsContainer.setPadding(1, 1, 1, 1);
    } else {
        tabsContainer.setPadding(0, 10, 0, 10);
    }

    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    selectedTabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_selectedTabTextColor,
            selectedTabTextColor);
    tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_textcolor, tabTextColor);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:bottombar.BottomBar.java

private void populateAttributes(Context context, AttributeSet attrs) {
    primaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary);
    screenWidth = MiscUtils.getScreenWidth(getContext());
    tenDp = MiscUtils.dpToPixel(getContext(), 10);
    maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168);

    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomBar, 0, 0);

    try {/*from w ww  .  j  a  v  a  2 s  . co  m*/
        tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0);
        isTabletMode = ta.getBoolean(R.styleable.BottomBar_bb_tabletMode, false);
        behaviors = ta.getInteger(R.styleable.BottomBar_bb_behavior, BEHAVIOR_NONE);
        inActiveTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_inActiveTabAlpha,
                isShiftingMode() ? DEFAULT_INACTIVE_SHIFTING_TAB_ALPHA : 1);
        activeTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_activeTabAlpha, 1);

        @ColorInt
        int defaultInActiveColor = isShiftingMode() ? Color.WHITE
                : ContextCompat.getColor(context, R.color.bb_inActiveBottomBarItemColor);
        int defaultActiveColor = isShiftingMode() ? Color.WHITE : primaryColor;

        inActiveTabColor = ta.getColor(R.styleable.BottomBar_bb_inActiveTabColor, defaultInActiveColor);
        activeTabColor = ta.getColor(R.styleable.BottomBar_bb_activeTabColor, defaultActiveColor);
        badgeBackgroundColor = ta.getColor(R.styleable.BottomBar_bb_badgeBackgroundColor, Color.RED);
        hideBadgeWhenActive = ta.getBoolean(R.styleable.BottomBar_bb_badgesHideWhenActive, true);
        titleTextAppearance = ta.getResourceId(R.styleable.BottomBar_bb_titleTextAppearance, 0);
        titleTypeFace = getTypeFaceFromAsset(ta.getString(R.styleable.BottomBar_bb_titleTypeFace));
        showShadow = ta.getBoolean(R.styleable.BottomBar_bb_showShadow, true);
    } finally {
        ta.recycle();
    }
}

From source file:com.jsibbold.zoomage.ZoomageView.java

public ZoomageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    scaleDetector = new ScaleGestureDetector(context, this);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleDetector, false);
    startScaleType = getScaleType();//from  ww w .ja  v a2  s  . c  o  m

    TypedArray values = context.obtainStyledAttributes(attrs, com.jsibbold.zoomage.R.styleable.ZoomageView);

    zoomable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_zoomable, true);
    translatable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_translatable, true);
    animateOnReset = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_animateOnReset,
            true);
    autoCenter = values.getBoolean(R.styleable.ZoomageView_zoomage_autoCenter, true);
    restrictBounds = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_restrictBounds,
            false);
    minScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_minScale, MIN_SCALE);
    maxScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_maxScale, MAX_SCALE);
    autoResetMode = AutoResetMode.Parser.fromInt(values
            .getInt(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_autoResetMode, AutoResetMode.UNDER));

    verifyScaleRange();

    values.recycle();
}

From source file:com.wl.tabguidance.utils.TabLayoutTitleStrip.java

public TabLayoutTitleStrip(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTS//from  www .j av a2 s .c  o m

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TabTitleStrip);
    try {
        setStripColor(typedArray.getColor(R.styleable.TabTitleStrip_nts_color, DEFAULT_STRIP_COLOR));
        setTitleSize(typedArray.getDimension(R.styleable.TabTitleStrip_nts_size, DEFAULT_TITLE_SIZE));
        setStripWeight(typedArray.getDimension(R.styleable.TabTitleStrip_nts_weight, DEFAULT_STRIP_WEIGHT));
        setStripFactor(typedArray.getFloat(R.styleable.TabTitleStrip_nts_factor, DEFAULT_STRIP_FACTOR));
        setStripType(typedArray.getInt(R.styleable.TabTitleStrip_nts_type, StripType.LINE_INDEX));
        setStripGravity(typedArray.getInt(R.styleable.TabTitleStrip_nts_gravity, StripGravity.BOTTOM_INDEX));

        setTypeface(typedArray.getString(R.styleable.TabTitleStrip_nts_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.TabTitleStrip_nts_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(typedArray.getColor(R.styleable.TabTitleStrip_nts_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.TabTitleStrip_nts_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(
                typedArray.getDimension(R.styleable.TabTitleStrip_nts_corners_radius, DEFAULT_CORNER_RADIUS));

        // Get titles
        String[] titles = null;
        try {
            final int titlesResId = typedArray.getResourceId(R.styleable.TabTitleStrip_nts_titles, 0);
            titles = titlesResId == 0 ? null : typedArray.getResources().getStringArray(titlesResId);
        } catch (Exception exception) {
            titles = null;
            exception.printStackTrace();
        } finally {
            if (titles == null) {
                if (isInEditMode()) {
                    titles = new String[new Random().nextInt(5) + 1];
                    Arrays.fill(titles, PREVIEW_TITLE);
                } else
                    titles = new String[0];
            }

            setTitles(titles);
        }

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });
    } finally {
        typedArray.recycle();
    }
}

From source file:com.appsummary.luoxf.myappsummary.navigationtabstrip.NavigationTabStrip.java

public NavigationTabStrip(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTS//from  w w  w . j a  v a2s .  c o m

    // Always draw
    setWillNotDraw(false);
    // More speed!
    setLayerType(LAYER_TYPE_HARDWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabStrip);
    try {
        setStripColor(typedArray.getColor(R.styleable.NavigationTabStrip_nts_color, DEFAULT_STRIP_COLOR));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_size, DEFAULT_TITLE_SIZE));
        setStripWeight(
                typedArray.getDimension(R.styleable.NavigationTabStrip_nts_weight, DEFAULT_STRIP_WEIGHT));
        setStripFactor(typedArray.getFloat(R.styleable.NavigationTabStrip_nts_factor, DEFAULT_STRIP_FACTOR));
        setStripType(typedArray.getInt(R.styleable.NavigationTabStrip_nts_type, StripType.LINE_INDEX));
        setStripGravity(
                typedArray.getInt(R.styleable.NavigationTabStrip_nts_gravity, StripGravity.BOTTOM_INDEX));

        setTypeface(typedArray.getString(R.styleable.NavigationTabStrip_nts_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabStrip_nts_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_corners_radius,
                DEFAULT_CORNER_RADIUS));

        // Get titles
        String[] titles = null;
        try {
            final int titlesResId = typedArray.getResourceId(R.styleable.NavigationTabStrip_nts_titles, 0);
            titles = titlesResId == 0 ? null : typedArray.getResources().getStringArray(titlesResId);
        } catch (Exception exception) {
            titles = null;
            exception.printStackTrace();
        } finally {
            if (titles == null) {
                if (isInEditMode()) {
                    titles = new String[new Random().nextInt(5) + 1];
                    Arrays.fill(titles, PREVIEW_TITLE);
                } else
                    titles = new String[0];
            }

            setTitles(titles);
        }

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });
    } finally {
        typedArray.recycle();
    }
}

From source file:com.gigamole.navigationtabstrip.NavigationTabStrip.java

public NavigationTabStrip(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTS/*from   www  .  j  av  a 2 s.com*/

    // Always draw
    setWillNotDraw(false);
    // Speed and fix for pre 17 API
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabStrip);
    try {
        setStripColor(typedArray.getColor(R.styleable.NavigationTabStrip_nts_color, DEFAULT_STRIP_COLOR));
        setTitleSize(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_size, DEFAULT_TITLE_SIZE));
        setStripWeight(
                typedArray.getDimension(R.styleable.NavigationTabStrip_nts_weight, DEFAULT_STRIP_WEIGHT));
        setStripFactor(typedArray.getFloat(R.styleable.NavigationTabStrip_nts_factor, DEFAULT_STRIP_FACTOR));
        setStripType(typedArray.getInt(R.styleable.NavigationTabStrip_nts_type, StripType.LINE_INDEX));
        setStripGravity(
                typedArray.getInt(R.styleable.NavigationTabStrip_nts_gravity, StripGravity.BOTTOM_INDEX));

        setTypeface(typedArray.getString(R.styleable.NavigationTabStrip_nts_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabStrip_nts_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabStrip_nts_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabStrip_nts_corners_radius,
                DEFAULT_CORNER_RADIUS));

        // Get titles
        String[] titles = null;
        try {
            final int titlesResId = typedArray.getResourceId(R.styleable.NavigationTabStrip_nts_titles, 0);
            titles = titlesResId == 0 ? null : typedArray.getResources().getStringArray(titlesResId);
        } catch (Exception exception) {
            titles = null;
            exception.printStackTrace();
        } finally {
            if (titles == null) {
                if (isInEditMode()) {
                    titles = new String[new Random().nextInt(5) + 1];
                    Arrays.fill(titles, PREVIEW_TITLE);
                } else
                    titles = new String[0];
            }

            setTitles(titles);
        }

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });
    } finally {
        typedArray.recycle();
    }
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

/**
 * Creates a view appropriate for displaying a list of GuidedActions, using the provided
 * inflater and container.//from  w  ww  .  jav  a 2 s.  co  m
 * <p>
 * <i>Note: Does not actually add the created view to the container; the caller should do
 * this.</i>
 * @param inflater The layout inflater to be used when constructing the view.
 * @param container The view group to be passed in the call to
 * <code>LayoutInflater.inflate</code>.
 * @return The view to be added to the caller's view hierarchy.
 */
public View onCreateView(LayoutInflater inflater, final ViewGroup container) {
    TypedArray ta = inflater.getContext().getTheme()
            .obtainStyledAttributes(R.styleable.LeanbackGuidedStepTheme);
    float keylinePercent = ta.getFloat(R.styleable.LeanbackGuidedStepTheme_guidedStepKeyline, 40);
    mMainView = (ViewGroup) inflater.inflate(onProvideLayoutId(), container, false);
    mContentView = mMainView
            .findViewById(mButtonActions ? R.id.guidedactions_content2 : R.id.guidedactions_content);
    mBgView = mMainView.findViewById(
            mButtonActions ? R.id.guidedactions_list_background2 : R.id.guidedactions_list_background);
    if (mMainView instanceof VerticalGridView) {
        mActionsGridView = (VerticalGridView) mMainView;
    } else {
        mActionsGridView = (VerticalGridView) mMainView
                .findViewById(mButtonActions ? R.id.guidedactions_list2 : R.id.guidedactions_list);
        if (mActionsGridView == null) {
            throw new IllegalStateException("No ListView exists.");
        }
        mActionsGridView.setWindowAlignmentOffsetPercent(keylinePercent);
        mActionsGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE);
        if (!mButtonActions) {
            mSubActionsGridView = (VerticalGridView) mMainView.findViewById(R.id.guidedactions_sub_list);
        }
    }
    mActionsGridView.setFocusable(false);
    mActionsGridView.setFocusableInTouchMode(false);

    // Cache widths, chevron alpha values, max and min text lines, etc
    Context ctx = mMainView.getContext();
    TypedValue val = new TypedValue();
    mEnabledChevronAlpha = getFloat(ctx, val, R.attr.guidedActionEnabledChevronAlpha);
    mDisabledChevronAlpha = getFloat(ctx, val, R.attr.guidedActionDisabledChevronAlpha);
    mTitleMinLines = getInteger(ctx, val, R.attr.guidedActionTitleMinLines);
    mTitleMaxLines = getInteger(ctx, val, R.attr.guidedActionTitleMaxLines);
    mDescriptionMinLines = getInteger(ctx, val, R.attr.guidedActionDescriptionMinLines);
    mVerticalPadding = getDimension(ctx, val, R.attr.guidedActionVerticalPadding);
    mDisplayHeight = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getHeight();

    mEnabledTextAlpha = Float
            .valueOf(ctx.getResources().getString(R.string.lb_guidedactions_item_unselected_text_alpha));
    mDisabledTextAlpha = Float
            .valueOf(ctx.getResources().getString(R.string.lb_guidedactions_item_disabled_text_alpha));
    mEnabledDescriptionAlpha = Float.valueOf(
            ctx.getResources().getString(R.string.lb_guidedactions_item_unselected_description_text_alpha));
    mDisabledDescriptionAlpha = Float.valueOf(
            ctx.getResources().getString(R.string.lb_guidedactions_item_disabled_description_text_alpha));
    return mMainView;
}