1

i would like to create this drawable object (without blue borders):
API 23
enter image description here

For API 23 it is correct.

But for: API 22
enter image description here
and API 16
enter image description here

are not correct.

Drawable code:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:height="100dp"
        android:width="100dp"
        android:gravity="center">

        <rotate xmlns:android="http://schemas.android.com/apk/res/android"
                android:fromDegrees="90"
                android:toDegrees="90">
            <shape
                android:shape="line">
                <stroke
                    android:width="1dp"
                    android:color="#000" />
            </shape>
        </rotate>
    </item>

    <item
        android:height="100dp"
        android:width="100dp"
        android:gravity="center">
            <shape
                android:shape="line">
                <stroke
                    android:width="1dp"
                    android:color="#000" />
            </shape>
    </item>

    <item
        android:height="75dp"
        android:width="75dp"
        android:gravity="center">
        <shape
            android:shape="oval">
            <stroke
                android:width="1dp"
                android:color="#000"/>
        </shape>
    </item>

    <item
        android:height="50dp"
        android:width="50dp"
        android:gravity="center">
        <shape
            android:shape="oval" >

            <stroke
                android:width="1dp"
                android:color="#000"/>
        </shape>
    </item>

</layer-list>

I would like to have drawable object same for these APIs. Can you help me please? Thank you very much.

t0m
  • 3,004
  • 31
  • 53
  • 5
    You should try adding `` to your circle definitions, which might be necessary to get rid of the opaque background. http://stackoverflow.com/questions/16098538/transparent-circle-with-border – Taig Feb 08 '16 at 01:22
  • Thank you @Taig! It's helped me. Seems that in old APIs the default color for a shape is black. – Daniel Argüelles Jul 06 '16 at 20:53
  • 1
    @Taig you should change your comment to be the answer. It solved the problem for me. – Leandroid Apr 03 '17 at 17:00

1 Answers1

-3

This is not possible for API lower than 21 (It is a Material Design feature included on Android 5.0):


Create Vector Drawables

In Android 5.0 (API Level 21) and above, you can define vector drawables, which scale without losing definition. You need only one asset file for a vector image, as opposed to an asset file for each screen density in the case of bitmap images. To create a vector image, you define the details of the shape inside a <vector> XML element

http://developer.android.com/training/material/drawables.html

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
  • 2
    t0m is not using `VectorDrawable` here, just plain old shapes, which should generally work for his use case. He could however use `VectorDrawable` with PNG rasterization for older API levels if `ShapeDrawable`s won't do the job. – Taig Feb 08 '16 at 01:15