Java Code Examples for androidx.appcompat.widget.TintTypedArray#getDimensionPixelSize()
The following examples show how to use
androidx.appcompat.widget.TintTypedArray#getDimensionPixelSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollapsingTextHelper.java From UIWidget with Apache License 2.0 | 6 votes |
public void setCollapsedTextAppearance(int resId) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, R.styleable.CollapsingTextAppearance); if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textColor)) { mCollapsedTextColor = a.getColorStateList(R.styleable.CollapsingTextAppearance_android_textColor); } if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textSize)) { mCollapsedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, (int) mCollapsedTextSize); } mCollapsedShadowColor = a.getInt(R.styleable.CollapsingTextAppearance_android_shadowColor, 0); mCollapsedShadowDx = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowDx, 0); mCollapsedShadowDy = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowDy, 0); mCollapsedShadowRadius = a.getFloat(R.styleable.CollapsingTextAppearance_android_shadowRadius, 0); a.recycle(); if (Build.VERSION.SDK_INT >= 16) { mCollapsedTypeface = readFontFamilyTypeface(resId); } recalculate(); }
Example 2
Source File: CollapsingTextHelper.java From UIWidget with Apache License 2.0 | 6 votes |
/** * 设置最大化状态Text样式id * * @param resId */ public void setExpandedTextAppearance(int resId) { TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, R.styleable.CollapsingTextAppearance); if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textColor)) { mExpandedTextColor = a.getColorStateList(R.styleable.CollapsingTextAppearance_android_textColor); } if (a.hasValue(R.styleable.CollapsingTextAppearance_android_textSize)) { mExpandedTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTextAppearance_android_textSize, (int) mExpandedTextSize); } mExpandedShadowColor = a.getInt( R.styleable.CollapsingTextAppearance_android_shadowColor, 0); mExpandedShadowDx = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowDx, 0); mExpandedShadowDy = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowDy, 0); mExpandedShadowRadius = a.getFloat( R.styleable.CollapsingTextAppearance_android_shadowRadius, 0); a.recycle(); if (Build.VERSION.SDK_INT >= 16) { mExpandedTypeface = readFontFamilyTypeface(resId); } recalculate(); }
Example 3
Source File: NavigationView.java From material-components-android with Apache License 2.0 | 6 votes |
/** * Creates a {@link MaterialShapeDrawable} to use as the {@code itemBackground} and wraps it in an * {@link InsetDrawable} for margins. * * @param a The TintTypedArray containing the resolved NavigationView style attributes. */ @NonNull private final Drawable createDefaultItemBackground(@NonNull TintTypedArray a) { int shapeAppearanceResId = a.getResourceId(R.styleable.NavigationView_itemShapeAppearance, 0); int shapeAppearanceOverlayResId = a.getResourceId(R.styleable.NavigationView_itemShapeAppearanceOverlay, 0); MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable( ShapeAppearanceModel.builder( getContext(), shapeAppearanceResId, shapeAppearanceOverlayResId) .build()); materialShapeDrawable.setFillColor( MaterialResources.getColorStateList( getContext(), a, R.styleable.NavigationView_itemShapeFillColor)); int insetLeft = a.getDimensionPixelSize(R.styleable.NavigationView_itemShapeInsetStart, 0); int insetTop = a.getDimensionPixelSize(R.styleable.NavigationView_itemShapeInsetTop, 0); int insetRight = a.getDimensionPixelSize(R.styleable.NavigationView_itemShapeInsetEnd, 0); int insetBottom = a.getDimensionPixelSize(R.styleable.NavigationView_itemShapeInsetBottom, 0); return new InsetDrawable(materialShapeDrawable, insetLeft, insetTop, insetRight, insetBottom); }