'ShapeableImageView's stroke is getting cut by borders
I have a ShapeableImageView here, with 5dp stroke:
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/profile_picture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:scaleType="centerCrop"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/profile_toolbar"
app:shapeAppearanceOverlay="@style/circular"
app:strokeColor="@color/dark_blue"
app:strokeWidth="5dp" />
This is the result:
Solution 1:[1]
i've been trying some stuff, and finally, adding a padding to the view fixed the problem
Solution 2:[2]
I don't think ShapeableImageView is supposed to use to draw border stroke. I think it is supposed to just clip its image resource to the specified shape.
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/profile_picture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:background="#FF0000"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_foreground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="@style/circular" />
Solution 3:[3]
only you need to give it padding may be 5dp will be suitable ( more or less )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nasreddine Bouchemel |
Solution 2 | hata |
Solution 3 | Noah Mohamed |