Nabeel
Nabeel

Reputation: 31

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.

Upvotes: 3

Views: 1399

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364694

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

Upvotes: 1

Saurabh Thorat
Saurabh Thorat

Reputation: 20714

Currently in v1.1.0, there's no MaterialImageView or MaterialImageButton.

But in v1.2.0, there's ShapeableImageView coming out which extends AppCompatImageView

Upvotes: 0

Related Questions