Detailed explanation of how to customize the color of progress bar in Android programming

This article describes the method of customizing the color of progress bar in Android programming. Share with you for your reference, as follows:

Look at the renderings first:

I always ask questions about various requirements. I think the default color of the system is very good, but PK. However, who calls us not demand personnel? Change it!

I can't help it. I can only look at the source code. Fortunately, I downloaded the source code. I have everything under sources \ base \ core \ res \ res \. To modify the color of the progress bar, I can only find progress. Because it is to change the style, I first find styles.xml

After finding the XML, go in and find:

This is the default rotation, but we don't modify this today. We want to change the color of the horizontal progress bar, so find:

You see, the system is related step by step, with high scalability and low coupling, so we just need to change how the progress bar is drawn, but the person responsible for drawing the progress bar is < item name = "Android: progressdrawable" > @ H_ 404_ 27 @ so we can find the progress_horizontal file under "drawable", and change it to change the color of the progress bar.

See, this is the layout condition drawn by the progress bar of the system

As long as we change this color value, we can change its color. The main change is < item Android: id = "@ Android: ID / progress" > @ H_ 404_ The color value under 27 @ is OK.

Having said so much, how to do it is very simple:

Create a new style.xml file under our project

Create a style tag, integrate the system default style, and then customize a new progressdrawable file, which will be referenced later in the progress in the layout.

Here is my ProgressBar_ Mini file, changing the color value of Android: endcolor = "#f5f5f5" Android: startcolor = "#bebe"

Finally, just quote it.

For more Android related content, readers who are interested can view the topics on this site: introduction and advanced tutorial of Android development, summary of Android debugging skills and common problem solutions, summary of Android multimedia operation skills (audio, video, recording, etc.), summary of Android basic component usage, summary of Android view skills Android layout skills summary and Android control usage summary

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>