Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ public partial class ImageButtonHandler : ViewHandler<IImageButton, ShapeableIma
{
protected override ShapeableImageView CreatePlatformView()
{
var platformView = new MauiShapeableImageView(Context);
// TODO: net11 - Remove MaterialShapeableImageView and always use MauiShapeableImageView
// once MauiShapeableImageView has public API changes that support Material3.
ShapeableImageView platformView = RuntimeFeature.IsMaterial3Enabled
? new MaterialShapeableImageView(Context)
: new MauiShapeableImageView(Context);

// These set the defaults so visually it matches up with other platforms
platformView.SetPadding(0, 0, 0, 0);
Expand Down
33 changes: 33 additions & 0 deletions src/Core/src/Platform/Android/MauiShapeableImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,37 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
SetPadding(0, 0, 0, 0);
}
}

// TODO: net11 - Remove this class and update MauiShapeableImageView to public API with the same changes.
internal class MaterialShapeableImageView : ShapeableImageView
{
public MaterialShapeableImageView(Context context) : base(MauiMaterialContextThemeWrapper.Create(context))
{
}

public MaterialShapeableImageView(Context context, IAttributeSet? attrs) : base(MauiMaterialContextThemeWrapper.Create(context), attrs)
{
}

public MaterialShapeableImageView(Context context, IAttributeSet? attrs, int defStyle) : base(MauiMaterialContextThemeWrapper.Create(context), attrs, defStyle)
{
}

protected MaterialShapeableImageView(nint javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}

protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
// The padding has a few issues. This is a workaround for the following issue:
// https://github.com/material-components/material-components-android/issues/2063

// ShapeableImageView combines ContentPadding with Padding and updates
// Padding with the result.
base.OnMeasure(widthMeasureSpec, heightMeasureSpec);

// We need to reset the padding to 0 to avoid a double padding.
SetPadding(0, 0, 0, 0);
}
}
}
Loading