Android: circular drawing shrinks borders

In the list of items view, I want to draw a circle with specific information inside. But the circle borders are not showing correctly.

This is part of my layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:azeoo="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="@dimen/schedule_workout_item_exercice_height"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="@dimen/keyline_1"
        android:orientation="horizontal">

        <!-- Exercice number -->

        <RelativeLayout
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:orientation="vertical">

            <RelativeLayout
                android:id="@+id/exercice_num_container"
                android:visibility="visible"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <TextView
                    android:id="@+id/exercice_num"
                    style="@style/ItemExerciceNum"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center_vertical|center_horizontal"
                    android:text="1" />

                THIS IS THE CIRCLE HERE:

                <View
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/circle_exercice_num" />

            </RelativeLayout>

        </RelativeLayout>

        <!-- Exercice informations -->

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingLeft="8dp">

        ...

      

Selectable circle_exercice_num.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="1.9"
    android:useLevel="false">
    <solid android:color="@android:color/transparent"/>
    <stroke
        android:width="1dp"
        android:color="@color/item_exercice_num"/>
</shape>

      

Result (even in development mode in Android Studio!):

enter image description here

Thanks for the help guys!

UPDATE

Ok guys, I haven't found a solution for this Android problem. So, I took this library: https://github.com/pavlospt/CircleView . And now it works well :)

+3


source to share


1 answer


//edit code layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:gravity="center"
            tools:context=".MainActivity" >
            <View
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:background="@drawable/circleshape" />
        </RelativeLayout>


    //drawable folder xml file circleshape.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="ring"
        android:thicknessRatio="1.9"
        android:useLevel="false" >
        <solid android:color="@android:color/transparent" />
        <stroke
            android:width="2dp"
            android:color="@android:color/darker_gray" />
    </shape>

      



+1


source







All Articles