Reputation: 871
XML
and not programatically
!Is it not possible to to set round corners through xml
& we have to use bitmap
?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_cornered_imageview"
android:src="@drawable/image" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My-Text"
android:textColor="@color/textbody"
android:layout_gravity="bottom|center"
android:textSize="40sp" />
<Button
android:id="@+id/button1"
android:layout_width="108dp"
android:layout_height="74dp"
android:background="@color/textbody"
android:layout_gravity="top|center"
android:text="Button" />
</FrameLayout>
</LinearLayout>
What i have tried ::
rounded_cornered_imageview.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
<stroke
android:color="@color/black"
android:width="1dp"
/>
</shape>
But its not working ... where i need to correct myself ?
Upvotes: 0
Views: 652
Reputation: 364
you can follow this below: on your gradle in dependencies
implementation 'com.makeramen:roundedimageview:2.3.0'
on your xml file
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/img_home_assistance"
android:layout_width="match_parent"
android:layout_height="123dp"
app:riv_corner_radius="@dimen/padding_margin_15"
android:layout_marginTop="6.8dp"
android:layout_marginLeft="7.3dp"
android:layout_marginRight="7.5dp"
android:src="@drawable/migrate"
android:scaleType="centerCrop"/>
Upvotes: 1