Transparent circle with border

后端 未结 10 1427
南方客
南方客 2020-12-04 10:48

I am trying to create a circle with only a border using XML in android:




        
相关标签:
10条回答
  • 2020-12-04 11:46

    You can use android inbuilt value for transparent as @android:color/transparent or use #0000 or #00000000

    for above starting for 4 digit first was for alpha and in 8 digit value first two digit was for same as alpha.

    When you just give 3 digit or 6 digit in color than default alpha value was ff you by passing in 4 digit or 8 digit value set that alpha of that color value

    0 讨论(0)
  • 2020-12-04 11:49
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
         android:innerRadiusRatio="2"
         android:shape="ring"
         android:thicknessRatio="1"
         android:useLevel="false">
    
        <gradient
            android:type="radial"
            android:gradientRadius="8dp"
            android:endColor="@color/colorDarkPurple"
            android:elevation="5dp"
        />
    
        <stroke
            android:width="2dp"
            android:color="@color/colorLilac"/>
    </shape>
    
    0 讨论(0)
  • 2020-12-04 11:51

    The stroke effect can be achieved drawing a transparent oval with the stroke of a required color (#000 in the example):

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <solid android:color="@android:color/transparent" />
        <stroke
            android:width="1dp"
            android:color="#000" />
        <size
            android:width="40dp"
            android:height="40dp" />
    </shape>
    
    0 讨论(0)
  • 2020-12-04 11:51

    If you can use Vector drawables try this

    <vector android:height="24dp" android:viewportHeight="512.0"
        android:viewportWidth="512.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
        <path android:fillColor="#FFFFFF" android:fillType="evenOdd"
            android:pathData="M0,0L512,0L512,512L0,512L0,0ZM256,511C396.8,511 511,396.8 511,256C511,115.2 396.8,1 256,1C115.2,1 1,115.2 1,256C1,396.8 115.2,511 256,511Z"
            android:strokeColor="#00000000" android:strokeWidth="1"/>
    </vector>
    
    0 讨论(0)
提交回复
热议问题