1

Помогите закруглить углы у Image Button

<ImageButton
        android:id="@+id/bottle"
        android:src="@drawable/bottle"
        android:background="@drawable/rouncorners"
        android:layout_width="100dp"
        android:layout_height="100dp"/>


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">


<corners android:radius="10dp"/>

</shape>

1 ответ 1

4

Надо еще в коде вызвать:

ImageView.setClipToOutline(true);

иначе ImageView не будет обрезаться по границам фона (то есть будет с острыми углами)

Как альтернативу можно использовать RoundedImageView:

<com.makeramen.roundedimageview.RoundedImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:src="@drawable/photo1"
    android:scaleType="fitCenter"
    app:riv_corner_radius="30dip"
/>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.