Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create circle inside another circle in Android

I need to create image for my camera app. I create a circle inside another circle it look fine when I see it on android studio but when run it on real device it was not same as it is. Here is image of both first one from real device and second from android studio.

image from real device Circle inside circle

Here is my code that I'm using to create it.

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Larger circle in white-->
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <padding android:top="5dp" android:bottom="5dp" android:right="5dp" android:left="5dp"/>
        <stroke
            android:width="1dp"
            android:color="#ffffff"/>
    </shape>
</item>
<!-- Smaller white circle in front -->
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <solid
            android:color="#ffffff"/>
    </shape>
</item>
 </layer-list>

What's the problem why it show different.

like image 549
Fiverr Projects Avatar asked Jan 04 '23 05:01

Fiverr Projects


1 Answers

Everything seems good, just add size property. Hope after that it will work for you.

<size android:height="40dp" android:width="40dp"/>

Example:

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

    <item>
        <shape android:shape="oval">
            <size
                android:width="40dp"
                android:height="40dp" />
            <padding
                android:bottom="5dp"
                android:left="5dp"
                android:right="5dp"
                android:top="5dp" />
            <stroke
                android:width="1dp"
                android:color="#ffffff" />
        </shape>
    </item>

    <item>
        <shape android:shape="oval">
            <size
                android:width="40dp"
                android:height="40dp" />
            <solid android:color="#ffffff" />
        </shape>
    </item>
</layer-list>

I used 40dp as size of width and height. You can change it as per your requirement.

like image 151
Ganesh Katikar Avatar answered Jan 06 '23 18:01

Ganesh Katikar