Example usage for android.content.res TypedArray getDimension

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

Introduction

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

Prototype

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

Source Link

Document

Retrieve a dimensional unit attribute at index.

Usage

From source file:org.getlantern.firetweet.view.TwidereToolbar.java

public TwidereToolbar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(getThemedContext(context, attrs, defStyleAttr), attrs, defStyleAttr);
    final TypedArray a = getContext().obtainStyledAttributes(attrs, new int[] { R.attr.elevation },
            defStyleAttr, 0);//w w  w  . j av  a2 s  . c o  m
    ViewCompat.setElevation(this, a.getDimension(0, 0));
    a.recycle();
}

From source file:com.beesham.beerac.ui.ScrollAwareFABBehavior.java

public int getToolbarHeight(Context context) {
    final TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { R.attr.actionBarSize });
    int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();//from ww  w .  j a  v  a 2 s  .  c  o m

    return toolbarHeight;
}

From source file:cnc.cad.rxjavatestapp.AvatarImageBehavior.java

public AvatarImageBehavior(Context context, AttributeSet attrs) {
    mContext = context;/*from   w ww .  j  a va2  s.  c  o  m*/

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarImageBehavior);
        mCustomFinalHeight = a.getDimension(R.styleable.AvatarImageBehavior_finalHeight, 0);
        a.recycle();
    }
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static float getSupportActionBarElevation(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { R.attr.elevation },
            R.attr.actionBarStyle, 0);// w  w w .  j ava2  s  . com
    try {
        return a.getDimension(0, 0);
    } finally {
        a.recycle();
    }
}

From source file:it.dex.movingimageview.activities.MainActivity.java

public int getActionBarHeight() {
    int mActionBarSize = 0;
    final TypedArray styledAttributes = getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();// w  w  w  .j  a v a 2 s  .co m
    return mActionBarSize;
}

From source file:in.zollet.abhilash.materialdesign.BezelImageView.java

public BezelImageView(Context context, AttributeSet attrs) {
    mContext = context;/*from   w  w w . j av  a  2  s .c om*/

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarImageBehavior);
        mCustomFinalYPosition = a.getDimension(R.styleable.AvatarImageBehavior_finalYPosition, 0);
        mCustomStartXPosition = a.getDimension(R.styleable.AvatarImageBehavior_startXPosition, 0);
        mCustomStartToolbarPosition = a.getDimension(R.styleable.AvatarImageBehavior_startToolbarPosition, 0);
        mCustomStartHeight = a.getDimension(R.styleable.AvatarImageBehavior_startHeight, 0);
        mCustomFinalHeight = a.getDimension(R.styleable.AvatarImageBehavior_finalHeight, 0);

        a.recycle();
    }

    init();

    mFinalLeftAvatarPadding = context.getResources().getDimension(R.dimen.spacing_normal);
}

From source file:com.snippet.widget.ViewIndicator.java

private void init(Context context) {
    TypedArray a = context.getTheme().obtainStyledAttributes(null, R.styleable.ViewIndicator, R.attr.viStyles,
            0);//  ww  w  .j  a v  a  2  s.  com
    float radiusDp = a.getDimension(R.styleable.ViewIndicator_vi_radius, DEFAULT_RADIUS);
    mRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, radiusDp,
            getResources().getDisplayMetrics());
    if (mRadius <= 0) {
        mRadius = DEFAULT_RADIUS;
    }
    float distanceDp = a.getDimension(R.styleable.ViewIndicator_vi_distance, DEFAULT_DISTANCE);
    mDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, distanceDp,
            getResources().getDisplayMetrics());
    if (mDistance <= 0) {
        mDistance = DEFAULT_DISTANCE;
    }
    a.recycle();
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static float getActionBarElevation(final Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return 0;
    @SuppressLint("InlinedApi")
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.elevation },
            android.R.attr.actionBarStyle, 0);
    try {/*  www . ja v a  2 s  .com*/
        return a.getDimension(0, 0);
    } finally {
        a.recycle();
    }
}

From source file:com.hgdendi.contactslist.common.IndexBar.java

/******************
 * common//from   w w w.j a  va2  s. c  o m
 ******************/

private void initSetting(Context context, AttributeSet attrs) {
    mOnTouchingLetterChangeListener = getDummyListener();
    mNavigators = new ArrayList<>(0);
    mFocusIndex = -1;

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.IndexBar);
    float textSize = typedArray.getDimension(R.styleable.IndexBar_letterSize, 8);
    int letterColor = typedArray.getColor(R.styleable.IndexBar_letterColor,
            ContextCompat.getColor(getContext(), android.R.color.white));
    mLetterSpacingExtra = typedArray.getFloat(R.styleable.IndexBar_letterSpacingExtra, 1.4f);
    int focusLetterColor = typedArray.getColor(R.styleable.IndexBar_focusLetterColor,
            ContextCompat.getColor(getContext(), android.R.color.white));
    typedArray.recycle();

    mPaint = new Paint();
    mPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mPaint.setAntiAlias(true);
    mPaint.setColor(letterColor);
    mPaint.setTextSize(textSize);

    mFocusPaint = new Paint();
    mFocusPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mFocusPaint.setAntiAlias(true);
    mFocusPaint.setFakeBoldText(true);
    mFocusPaint.setTextSize(textSize);
    mFocusPaint.setColor(focusLetterColor);

}

From source file:com.fuav.android.view.viewPager.TabPageIndicator.java

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

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPageIndicator);
    mTextSize = a.getDimension(R.styleable.TabPageIndicator_android_textSize, 15f);

    a.recycle();//from w ww  .  j a  va2 s.c  o  m

    setHorizontalScrollBarEnabled(false);

    mTabLayout = new LinearLayout(getContext());
    addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
}