6

I am trying to do my custom progress bar, for that I created a spinner_inner and a spinner_outer, but my inner size is to large and overlaps the outer.

Image

my activity

   <ProgressBar
        style="@style/Spinner"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:indeterminateDrawable="@drawable/loading" />

    <TextView
        android:id="@+id/login_status_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:fontFamily="sans-serif-light"
        android:text="@string/login_progress_signing_in"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

my style

<style name="Spinner">
    <item name="android:indeterminate">true</item>
    <item name="android:indeterminateDrawable">@drawable/spinner_outer</item>
    <item name="android:indeterminateDuration">2000</item>
    <item name="android:indeterminateOnly">true</item>
</style>

my xml

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

<item android:drawable="@drawable/spinner_inner"/>
<item>
    <rotate
        android:fromDegrees="0"
        android:interpolator="@android:anim/linear_interpolator"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="360" >
        <bitmap
            android:antialias="true"
            android:filter="true"
            android:src="@drawable/spinner_outer" />
    </rotate>
</item>

</layer-list>

I had already searched for an answer, but no success.

peterh
  • 11,875
  • 18
  • 85
  • 108
firetrap
  • 1,947
  • 3
  • 24
  • 39
  • hello. tell me please what is @drawable/spinner_inner,@drawable/spinner_outer",@drawable/loading? – Monica Feb 01 '21 at 08:52
  • 1
    The drawables are the images, the spinner_outer is the multi color circle and the spinner_,inner is the blue face – firetrap Feb 01 '21 at 09:31

1 Answers1

15

So after nobody answered me, I found my own way.

The layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone" >

<RelativeLayout
    android:id="@+id/relative_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/image_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/spinner_inner"
        android:layout_centerInParent="true" />

    <ProgressBar
        android:id="@+id/progress"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:indeterminateDrawable="@drawable/loading"
        android:visibility="visible" />
</RelativeLayout>

<TextView
    android:id="@+id/status_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16dp"
    android:fontFamily="sans-serif-light"
    android:text="@string/loading_data"
    android:textAppearance="?android:attr/textAppearanceMedium" />

The out spinner

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

    <item>
        <rotate
            android:fromDegrees="0"
            android:interpolator="@android:anim/linear_interpolator"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toDegrees="360" >
            <bitmap
                android:antialias="true"
                android:filter="true"
                android:src="@drawable/spinner_outer" />
        </rotate>
    </item>

</layer-list>
peterh
  • 11,875
  • 18
  • 85
  • 108
firetrap
  • 1,947
  • 3
  • 24
  • 39
  • 1
    You're a lifesaver. I needed this and it works perfectly on the few devices I tested on. Thanks a bunch! – pqsk Jan 05 '14 at 19:46
  • 3
    can you tell what is @drawable/spinner_inner,@drawable/spinner_outer",@drawable/loading ?? – CoronaPintu Mar 29 '14 at 10:48