0

I have ImageButton with background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
    <solid android:color="@color/colorAccent" />
</shape>

But when I add src to the ImageButton, an Image goes out of borders. Without src:

<androidx.appcompat.widget.AppCompatImageButton
    android:id="@+id/photo"
    app:layout_constraintDimensionRatio="1:1"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toLeftOf="@id/bgPhoto"
    app:layout_constraintTop_toTopOf="parent"
    android:background="@drawable/profile_photo_too_roundcorner"
    android:scaleType="centerCrop"
    android:layout_gravity="center"
    android:layout_marginStart="5dp"
    android:layout_marginEnd="15dp"/>

enter image description here

With src:

<androidx.appcompat.widget.AppCompatImageButton
    android:id="@+id/photo"
    app:layout_constraintDimensionRatio="1:1"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toLeftOf="@id/bgPhoto"
    app:layout_constraintTop_toTopOf="parent"
    android:background="@drawable/profile_photo_too_roundcorner"
    android:src="@drawable/plus_photo"
    android:scaleType="centerCrop"
    android:layout_gravity="center"
    android:layout_marginStart="5dp"
    android:layout_marginEnd="15dp"/>

enter image description here

Arsen Tatraev
  • 470
  • 1
  • 4
  • 16

0 Answers0