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

    <stroke android:width="30dp"
            android:color="#51000000"
        />
</shape>

It gives a "half-inner-half-outer" stroke. What I need is outer semitransparent stroke only. Can it be done?

What I have is What I have

What I need is What I need

Thanks

Community
  • 1
  • 1
MobileX
  • 409
  • 4
  • 13

8 Answers8

2

you can check this shape created using layer list with it's items.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="oval" >
            <solid android:color="#fff" />
        </shape>
    </item>

    <item >
        <shape android:shape="oval">
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="50dp"
                android:color="#30000000" />
        </shape>
    </item>

</layer-list>
santosh kumar
  • 2,952
  • 1
  • 15
  • 27
1

I've found no way to do that other than the following:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="oval">
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="@dimen/stroke_width"
                android:color="#33000000" />
        </shape>
    </item>

    <item >
        <shape android:shape="oval" >
            <solid android:color="#fff" />
            <stroke
                android:width="@dimen/stroke_width"
                android:color="@android:color/transparent">
            </stroke>
        </shape>
    </item>
</layer-list>
MobileX
  • 409
  • 4
  • 13
0

if you add alpha for stroke color the inner half is without transparent and outer is transparent.this is how stroke color works.if you don't want inner circle use color without Alpha and adjust Hexcode.

Anjal Saneen
  • 3,109
  • 23
  • 38
  • Can you provide a reference from where you get that? – Iulian Popescu Jan 11 '17 at 12:29
  • "the inner half is without transparent and outer is transparent" - can you see the attached image? The both halfs are transparent. Also, could you provide a markup, plz? – MobileX Jan 11 '17 at 12:31
0

Try adding android:innerRadius="0dp" for shape attribute -

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
>
<solid android:color="#ffffff"/>

<stroke android:width="4dp"
    android:color="#51000000"
    />
</shape>
Anindita Pani
  • 544
  • 3
  • 6
0

This is Android studio XML preview bug.look like The image you shown above from Android studio xml preview.actually there is no inner and outer layer.

Anjal Saneen
  • 3,109
  • 23
  • 38
0

Try This: (Change dimens and colors to fit your needs)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <stroke android:width="@dimen/default_stroke_size_small" android:color="@color/colorDimBlack"/>
        </shape>
    </item>

    <item>
        <shape android:shape="oval">
            <stroke android:width="@dimen/default_stroke_size_small" android:color="@android:color/transparent"/>
            <solid android:color="@color/colorWhite"/>
        </shape>
    </item>
</layer-list>
Tamim Attafi
  • 2,253
  • 2
  • 17
  • 34
-1

update your code to this:

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

    <stroke
        android:width="30dp"
        android:color="#000000" /> <--- this line you have to change
</shape>
Anjali
  • 1
  • 1
  • 13
  • 20
-2

You are missing one f in your first color. Thus it's creating a half visible pattern

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

    <stroke android:width="30dp"
        android:color="#51000000"
        />
</shape>
Sadiq Md Asif
  • 882
  • 6
  • 18