Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No ImageView/ImageButton in Material Components (Android)

So I have styled my android app with material components but didn't found any replacement for ImageView and/or ImageButton.

like image 301
Nabeel Avatar asked Sep 10 '26 11:09

Nabeel


1 Answers

About the ImageView you can use the ShapeableImageView which extends the AppCompatImageView.

You can use something like:

<com.google.android.material.imageview.ShapeableImageView
    android:scaleType="centerCrop"
    android:adjustViewBounds="true"
    app:shapeAppearanceOverlay="@style/customImageViewRounded"
    app:srcCompat="@drawable/...."

with:

  <style name="customImageViewRounded" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">32dp</item>

    <item name="cornerFamilyBottomRight">cut</item>
    <item name="cornerSizeBottomRight">50%</item>
    <item name="cornerSizeBottomLeft">0dp</item>
  </style>

enter image description here

like image 112
Gabriele Mariotti Avatar answered Sep 13 '26 06:09

Gabriele Mariotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!