Customize the spinner image of progressbar

Source: Internet
Author: User

I haven't updated my blog for a long time. I was too busy some time ago. After a while, I had a lot of new gains. Today, I will summarize the spinner image for implementing the custom progressbar. In fact, this function is very simple. I just think that sometimes it may not be possible to implement this requirement quickly. I will record it here today, it's a note.

Progressbar provides the void setindeterminatedrawable (drawabled) method to set the spinner. Remember that to use this method, you must call setindeterminate (booleanb) to study the android source code, the setindeterminatedrawable method is implemented as follows:

 public void setIndeterminateDrawable(Drawable d) {        if (d != null) {            d.setCallback(this);        }        mIndeterminateDrawable = d;        if (mIndeterminate) {            mCurrentDrawable = d;            postInvalidate();        }    }

It determines the mindeterminate variable, and the setindeterminate method is used to set this variable. The source code of progressbar is not complex. You can take a look.
If we follow setindeterminatedrawable

This method may not work. I wrote it as follows:
    <item>        <rotate android:drawable="@drawable/loading_spinner"            android:fromDegrees="0.0"            android:toDegrees="360.0"            android:pivotX="50.0%"            android:pivotY="50.0%"/>    </item>

Put it under the drawable folder. After running the file, the spinner does not turn it. I really don't know why. Finally, I read the android source code, which is written as follows:

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"    android:drawable="@drawable/loading_spinner"    android:pivotX="50%"    android:pivotY="50%"/>

In this way, you can write it.

Sometimes, it is very important to consider the way of thinking about the problem. When there is no way to get through, think about whether there are other ideas. Android has the source code for reference, which can help us solve many problems, haha. I will study the source code in the future.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.