Open top menu

 The ImageView design in multiple Shape In android .

In this blog we will implement multiple ImageView Shape xml class in android.

activity_main.xml.
...................................................................................................................................................................

<LinearLayout 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:orientation="vertical"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/profile"
        android:padding="30dp"
        android:background="@drawable/image_ovalshape"
        android:scaleType="fitXY" />

</LinearLayout>
...................................................................................................................................................................


Imaige view in Oval shape xml .show view.



image_ovalshape.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="oval">
   
  <gradient 
    android:type="radial"
    android:gradientRadius="20"
    android:centerX=".6"
    android:centerY=".35"
    android:startColor="#a6cded"
    android:endColor="#a6cded" />
  
  <size 
    android:width="100dp"
    android:height="100dp"/>
</shape>
...................................................................................................................................................................

ImageView in rectangle shape.


image_racshape.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="15dp">
 <solid android:color="@color/gray"/>

    <corners
     android:bottomRightRadius="0dp"
     android:bottomLeftRadius="0dp"
     android:topLeftRadius="10dp"
     android:topRightRadius="10dp"/>

  <stroke android:width="2dip" android:color="#dce0e2" />  
</shape>
...................................................................................................................................................................
ImageView In Ring Shape.



image_ringshape.xml.
...................................................................................................................................................................

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

    <stroke
        android:width="3dp"
        android:color="#776da8" />

    <corners
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />

</shape>.
...................................................................................................................................................................

ImageView in Border View in Oval hsape.

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

    <solid android:color="#a6cded" />

    <stroke
        android:width="7dp"
        android:color="#776da8" />

    <corners
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />

</shape>
...................................................................................................................................................................

ImageView In Rounded Shape.


rounded_imageview.xml.
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="15dp">
 <solid android:color="#e5d41b"/>

    <corners
     android:bottomRightRadius="20dp"
     android:bottomLeftRadius="20dp"
     android:topLeftRadius="20dp"
     android:topRightRadius="20dp"/>

  <stroke android:width="7dip" android:color="#32c24d" />  
</shape>
................................................................................................................................................................


ImageView In Border With transparent Background.


border_transperent.xml.
...................................................................................................................................................................

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

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

    <stroke
        android:width="4dp"
        android:color="#ffffff" />

    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

</shape>
...................................................................................................................................................................


ImageView In Border used two or three color in boder gradient xml class.

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

    <item>
        <shape android:shape="rectangle" >
            <gradient
                android:angle="90"
                android:centerColor="@color/light_orange"
                android:endColor="@color/abs__background_holo_dark"
                android:startColor="@color/light_orange" />
        </shape>
    </item>
    <item
        android:bottom="6dp"
        android:left="3dp"
        android:right="3dp"
        android:top="2dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/purple_green" />
        </shape>
    </item>

</layer-list>
...................................................................................................................................................................


 try ...

0 comments