-1

Seems like shape padding doesn't work on pre 6 Android. I'm trying to add padding to custom ProgressBar background gradient and that what I have:

Android 6.0:

enter image description here

Android 5.0 and below:

enter image description here

pb_shape.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">

    <shape android:shape="rectangle">

        <corners android:radius="12dip" />

        <stroke
            android:width="1dip"
            android:color="@color/primary_white" />

        <gradient
            android:angle="270"
            android:centerColor="@color/primary_black"
            android:centerY="0.5"
            android:endColor="@color/primary_black"
            android:gradientRadius="12dip"
            android:startColor="@color/primary_black" />

        <!--This not working pre 6 android-->
        <padding
            android:bottom="4dp"
            android:left="4dp"
            android:right="4dp"
            android:top="4dp" />
    </shape>
</item>


<item android:id="@android:id/progress">
    <clip>
        <shape>
            <corners android:radius="12dip" />
            <gradient
                android:angle="0"
                android:endColor="@color/primary_teal"
                android:startColor="@color/primary_blue_dark" />
        </shape>
    </clip>
</item>

I've already tried to wrap those both items in distinct xml files and set padding there like that but it takes no effect:

 <item
    android:bottom="4dp"
    android:left="4dp"
    android:right="4dp"
    android:top="4dp"
    android:drawable="@drawable/pb_gradient_bg"
    />

Any ideas what causes this behavior and what could be the solution?

AnZ
  • 1,040
  • 24
  • 54

1 Answers1

0

Seems like I found a way round for this. It was needed to create transparent stroke for gradient with needed width and it does exactly what was needed.

For solution check my answer in similar question here

Happy coding :)

Community
  • 1
  • 1
AnZ
  • 1,040
  • 24
  • 54