0

I am trying to create rounded shape Image-view not the square shape in Android Studio (like the one from Whats-app).

This is my xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/background"
    tools:context="com.example.ska89.xxxxxx.MainActivity">

    <ImageView
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:id="@+id/imageView2"
        android:src="@drawable/logo"
        android:layout_marginTop="64dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:adjustViewBounds="false"
        android:clickable="false" />
</RelativeLayout>

Thank you.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
GI HYUN NAM
  • 41
  • 1
  • 7

1 Answers1

3

Create a xml file e.g circle_shape.xml in your drawable folder and write the following code something like this

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

    <solid
        android:color="@color/colorRound"/>

    <size
        android:width="50dp"
        android:height="50dp"/>
</shape>

then use this circle_shape.xml in your imageView as background something like this

<ImageView
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:id="@+id/imageView2"
    android:src="@drawable/logo"
    android:layout_marginTop="64dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:adjustViewBounds="false"
    android:background="@drawable/circle_shape"
    android:clickable="false" />
Masum
  • 4,879
  • 2
  • 23
  • 28