com.google.android.material.shape.MaterialShapeDrawable Java Examples
The following examples show how to use
com.google.android.material.shape.MaterialShapeDrawable.
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: MotionLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #2
Source File: BottomSheetBehavior.java From bottomsheetrecycler with Apache License 2.0 | 6 votes |
private void createMaterialShapeDrawable( Context context, AttributeSet attrs, boolean hasBackgroundTint, @Nullable ColorStateList bottomSheetColor) { if (this.shapeThemingEnabled) { this.shapeAppearanceModelDefault = new ShapeAppearanceModel(context, attrs, R.attr.bottomSheetStyle, DEF_STYLE_RES); this.materialShapeDrawable = new MaterialShapeDrawable(shapeAppearanceModelDefault); this.materialShapeDrawable.initializeElevationOverlay(context); if (hasBackgroundTint && bottomSheetColor != null) { materialShapeDrawable.setFillColor(bottomSheetColor); } else { // If the tint isn't set, use the theme default background color. TypedValue defaultColor = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.colorBackground, defaultColor, true); materialShapeDrawable.setTint(defaultColor.data); } } }
Example #3
Source File: BottomAppBarMainDemoFragment.java From material-components-android with Apache License 2.0 | 6 votes |
private void setUpBottomAppBarShapeAppearance() { ShapeAppearanceModel fabShapeAppearanceModel = fab.getShapeAppearanceModel(); boolean cutCornersFab = fabShapeAppearanceModel.getBottomLeftCorner() instanceof CutCornerTreatment && fabShapeAppearanceModel.getBottomRightCorner() instanceof CutCornerTreatment; BottomAppBarTopEdgeTreatment topEdge = cutCornersFab ? new BottomAppBarCutCornersTopEdge( bar.getFabCradleMargin(), bar.getFabCradleRoundedCornerRadius(), bar.getCradleVerticalOffset()) : new BottomAppBarTopEdgeTreatment( bar.getFabCradleMargin(), bar.getFabCradleRoundedCornerRadius(), bar.getCradleVerticalOffset()); MaterialShapeDrawable babBackground = (MaterialShapeDrawable) bar.getBackground(); babBackground.setShapeAppearanceModel( babBackground.getShapeAppearanceModel().toBuilder().setTopEdge(topEdge).build()); }
Example #4
Source File: BottomSheetBehavior.java From material-components-android with Apache License 2.0 | 6 votes |
private void createMaterialShapeDrawable( @NonNull Context context, AttributeSet attrs, boolean hasBackgroundTint, @Nullable ColorStateList bottomSheetColor) { if (this.shapeThemingEnabled) { this.shapeAppearanceModelDefault = ShapeAppearanceModel.builder(context, attrs, R.attr.bottomSheetStyle, DEF_STYLE_RES) .build(); this.materialShapeDrawable = new MaterialShapeDrawable(shapeAppearanceModelDefault); this.materialShapeDrawable.initializeElevationOverlay(context); if (hasBackgroundTint && bottomSheetColor != null) { materialShapeDrawable.setFillColor(bottomSheetColor); } else { // If the tint isn't set, use the theme default background color. TypedValue defaultColor = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.colorBackground, defaultColor, true); materialShapeDrawable.setTint(defaultColor.data); } } }
Example #5
Source File: MaterialAlertDialogBuilder.java From material-components-android with Apache License 2.0 | 6 votes |
@NonNull @Override public AlertDialog create() { AlertDialog alertDialog = super.create(); Window window = alertDialog.getWindow(); /* {@link Window#getDecorView()} should be called before any changes are made to the Window * as it locks in attributes and affects layout. */ View decorView = window.getDecorView(); if (background instanceof MaterialShapeDrawable) { ((MaterialShapeDrawable) background).setElevation(ViewCompat.getElevation(decorView)); } Drawable insetDrawable = MaterialDialogs.insetDrawable(background, backgroundInsets); window.setBackgroundDrawable(insetDrawable); decorView.setOnTouchListener(new InsetDialogOnTouchListener(alertDialog, backgroundInsets)); return alertDialog; }
Example #6
Source File: CoordinatorLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #7
Source File: AppBarLayout.java From material-components-android with Apache License 2.0 | 6 votes |
private void startLiftOnScrollElevationOverlayAnimation( @NonNull final MaterialShapeDrawable background, boolean lifted) { float appBarElevation = getResources().getDimension(R.dimen.design_appbar_elevation); float fromElevation = lifted ? 0 : appBarElevation; float toElevation = lifted ? appBarElevation : 0; if (elevationOverlayAnimator != null) { elevationOverlayAnimator.cancel(); } elevationOverlayAnimator = ValueAnimator.ofFloat(fromElevation, toElevation); elevationOverlayAnimator.setDuration( getResources().getInteger(R.integer.app_bar_elevation_anim_duration)); elevationOverlayAnimator.setInterpolator(AnimationUtils.LINEAR_INTERPOLATOR); elevationOverlayAnimator.addUpdateListener( new AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator valueAnimator) { background.setElevation((float) valueAnimator.getAnimatedValue()); } }); elevationOverlayAnimator.start(); }
Example #8
Source File: MaterialButtonHelper.java From material-components-android with Apache License 2.0 | 6 votes |
@Nullable private MaterialShapeDrawable getMaterialShapeDrawable(boolean getSurfaceColorStrokeDrawable) { if (rippleDrawable != null && rippleDrawable.getNumberOfLayers() > 0) { if (IS_LOLLIPOP) { InsetDrawable insetDrawable = (InsetDrawable) rippleDrawable.getDrawable(0); LayerDrawable layerDrawable = (LayerDrawable) insetDrawable.getDrawable(); return (MaterialShapeDrawable) layerDrawable.getDrawable(getSurfaceColorStrokeDrawable ? 0 : 1); } else { return (MaterialShapeDrawable) rippleDrawable.getDrawable(getSurfaceColorStrokeDrawable ? 0 : 1); } } return null; }
Example #9
Source File: MaterialDatePicker.java From material-components-android with Apache License 2.0 | 6 votes |
@NonNull @Override public final Dialog onCreateDialog(@Nullable Bundle bundle) { Dialog dialog = new Dialog(requireContext(), getThemeResId(requireContext())); Context context = dialog.getContext(); fullscreen = isFullscreen(context); int surfaceColor = MaterialAttributes.resolveOrThrow( context, R.attr.colorSurface, MaterialDatePicker.class.getCanonicalName()); background = new MaterialShapeDrawable( context, null, R.attr.materialCalendarStyle, R.style.Widget_MaterialComponents_MaterialCalendar); background.initializeElevationOverlay(context); background.setFillColor(ColorStateList.valueOf(surfaceColor)); background.setElevation(ViewCompat.getElevation(dialog.getWindow().getDecorView())); return dialog; }
Example #10
Source File: BadgeDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
private BadgeDrawable(@NonNull Context context) { this.contextRef = new WeakReference<>(context); ThemeEnforcement.checkMaterialTheme(context); Resources res = context.getResources(); badgeBounds = new Rect(); shapeDrawable = new MaterialShapeDrawable(); badgeRadius = res.getDimensionPixelSize(R.dimen.mtrl_badge_radius); badgeWidePadding = res.getDimensionPixelSize(R.dimen.mtrl_badge_long_text_horizontal_padding); badgeWithTextRadius = res.getDimensionPixelSize(R.dimen.mtrl_badge_with_text_radius); textDrawableHelper = new TextDrawableHelper(/* delegate= */ this); textDrawableHelper.getTextPaint().setTextAlign(Paint.Align.CENTER); this.savedState = new SavedState(context); setTextAppearanceResource(R.style.TextAppearance_MaterialComponents_Badge); }
Example #11
Source File: DropdownMenuEndIconDelegate.java From material-components-android with Apache License 2.0 | 6 votes |
private void addRippleEffect(@NonNull AutoCompleteTextView editText) { if (editText.getKeyListener() != null) { return; } int boxBackgroundMode = textInputLayout.getBoxBackgroundMode(); MaterialShapeDrawable boxBackground = textInputLayout.getBoxBackground(); int rippleColor = MaterialColors.getColor(editText, R.attr.colorControlHighlight); int[][] states = new int[][] { new int[] {android.R.attr.state_pressed}, new int[] {}, }; if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_OUTLINE) { addRippleEffectOnOutlinedLayout(editText, rippleColor, states, boxBackground); } else if (boxBackgroundMode == TextInputLayout.BOX_BACKGROUND_FILLED) { addRippleEffectOnFilledLayout(editText, rippleColor, states, boxBackground); } }
Example #12
Source File: FlowLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #13
Source File: BottomSheetBehavior.java From Mysplash with GNU Lesser General Public License v3.0 | 6 votes |
private void createMaterialShapeDrawable( @NonNull Context context, AttributeSet attrs, boolean hasBackgroundTint, @Nullable ColorStateList bottomSheetColor) { if (this.shapeThemingEnabled) { this.shapeAppearanceModelDefault = ShapeAppearanceModel.builder(context, attrs, R.attr.bottomSheetStyle, DEF_STYLE_RES) .build(); this.materialShapeDrawable = new MaterialShapeDrawable(shapeAppearanceModelDefault); this.materialShapeDrawable.initializeElevationOverlay(context); if (hasBackgroundTint && bottomSheetColor != null) { materialShapeDrawable.setFillColor(bottomSheetColor); } else { // If the tint isn't set, use the theme default background color. TypedValue defaultColor = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.colorBackground, defaultColor, true); materialShapeDrawable.setTint(defaultColor.data); } } }
Example #14
Source File: AppBarLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #15
Source File: ElevationAnimationDemoFragment.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public View onCreateDemoView( LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) { View view = layoutInflater.inflate( R.layout.cat_elevation_animation_fragment, viewGroup, false /* attachToRoot */); TextView translationZLabelView = view.findViewById(R.id.translation_z_label); float maxTranslationZ = getResources().getDimension(R.dimen.cat_elevation_max_translation_z); int maxTranslationZDp = (int) (maxTranslationZ / getResources().getDisplayMetrics().density); translationZLabelView.setText( getString(R.string.cat_elevation_animation_label, maxTranslationZDp)); MaterialShapeDrawable materialShapeDrawable = MaterialShapeDrawable.createWithElevationOverlay(view.getContext()); ViewCompat.setBackground(view, materialShapeDrawable); setTranslationZ(view, materialShapeDrawable, maxTranslationZ); startTranslationZAnimation(view, materialShapeDrawable, maxTranslationZ); return view; }
Example #16
Source File: Toolbar.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #17
Source File: RecyclerView.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #18
Source File: Button.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #19
Source File: EditText.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #20
Source File: GridLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #21
Source File: RelativeLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #22
Source File: ImageView.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #23
Source File: FrameLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #24
Source File: CollapsingToolbarLayout.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #25
Source File: View.java From Carbon with Apache License 2.0 | 6 votes |
private void updateCorners() { if (Carbon.IS_LOLLIPOP_OR_HIGHER) { setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(android.view.View view, Outline outline) { if (Carbon.isShapeRect(shapeModel, boundsRect)) { outline.setRect(0, 0, getWidth(), getHeight()); } else { shadowDrawable.setBounds(0, 0, getWidth(), getHeight()); shadowDrawable.setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER); shadowDrawable.getOutline(outline); } } }); } boundsRect.set(shadowDrawable.getBounds()); shadowDrawable.getPathForSize(getWidth(), getHeight(), cornersMask); }
Example #26
Source File: MaterialCardViewHelper.java From material-components-android with Apache License 2.0 | 5 votes |
public MaterialCardViewHelper( @NonNull MaterialCardView card, AttributeSet attrs, int defStyleAttr, @StyleRes int defStyleRes) { materialCardView = card; bgDrawable = new MaterialShapeDrawable(card.getContext(), attrs, defStyleAttr, defStyleRes); bgDrawable.initializeElevationOverlay(card.getContext()); bgDrawable.setShadowColor(Color.DKGRAY); ShapeAppearanceModel.Builder shapeAppearanceModelBuilder = bgDrawable.getShapeAppearanceModel().toBuilder(); TypedArray cardViewAttributes = card.getContext() .obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr, R.style.CardView); if (cardViewAttributes.hasValue(R.styleable.CardView_cardCornerRadius)) { // If cardCornerRadius is set, let it override the shape appearance. shapeAppearanceModelBuilder.setAllCornerSizes( cardViewAttributes.getDimension(R.styleable.CardView_cardCornerRadius, 0)); } foregroundContentDrawable = new MaterialShapeDrawable(); setShapeAppearanceModel(shapeAppearanceModelBuilder.build()); Resources resources = card.getResources(); // TODO(b/145298914): support custom sizing checkedIconMargin = resources.getDimensionPixelSize(R.dimen.mtrl_card_checked_icon_margin); checkedIconSize = resources.getDimensionPixelSize(R.dimen.mtrl_card_checked_icon_size); cardViewAttributes.recycle(); }
Example #27
Source File: FrameLayout.java From Carbon with Apache License 2.0 | 5 votes |
@Override public void setShapeModel(@NotNull ShapeAppearanceModel model) { this.shapeModel = model; shadowDrawable = new MaterialShapeDrawable(shapeModel); if (getWidth() > 0 && getHeight() > 0) updateCorners(); if (!Carbon.IS_LOLLIPOP_OR_HIGHER) postInvalidate(); }
Example #28
Source File: RelativeLayout.java From Carbon with Apache License 2.0 | 5 votes |
@Override public void setShapeModel(@NotNull ShapeAppearanceModel model) { this.shapeModel = model; shadowDrawable = new MaterialShapeDrawable(shapeModel); if (getWidth() > 0 && getHeight() > 0) updateCorners(); if (!Carbon.IS_LOLLIPOP_OR_HIGHER) postInvalidate(); }
Example #29
Source File: View.java From Carbon with Apache License 2.0 | 5 votes |
@Override public void setShapeModel(@NotNull ShapeAppearanceModel model) { this.shapeModel = model; shadowDrawable = new MaterialShapeDrawable(shapeModel); if (getWidth() > 0 && getHeight() > 0) updateCorners(); if (!Carbon.IS_LOLLIPOP_OR_HIGHER) postInvalidate(); }
Example #30
Source File: MaterialToolbarTest.java From material-components-android with Apache License 2.0 | 5 votes |
@Test public void givenNoElevation_whenSetElevation_setsMaterialShapeDrawableElevation() { MaterialToolbar materialToolbar = inflate(R.layout.test_toolbar); ViewCompat.setElevation(materialToolbar, elevation); assertThat(materialToolbar.getBackground()).isInstanceOf(MaterialShapeDrawable.class); assertThat(getMaterialShapeDrawable(materialToolbar).getElevation()).isEqualTo(elevation); }