Fiverr Projects
Fiverr Projects

Reputation: 311

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.

Upvotes: 4

Views: 4853

Answers (2)

Ganesh Katikar
Ganesh Katikar

Reputation: 2690

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.

Upvotes: 11

W.Dan
W.Dan

Reputation: 86

I think it's because your device's OS doesn't support attributes like "android:top" "android:bottom".

Upvotes: 0

Related Questions