Two ways to customize load schedule for Android
This paper will use two methods to write the progress of similar vehicle load
Add the for loop with the addview method of LinearLayout
Method of using custom control
First screenshot
1. Add the for loop with the addview method of LinearLayout
1.1 processtest01. XML file:
1.2 sub layout view01 of LinearLayout xml
1.3 ProcessTest01. java
1.4 two picture elements with boundaries are involved here
The final screenshot
This method has both advantages and disadvantages. This method is simple and easy to understand, consumes less memory, runs fast, etc. However, if you want different colors, you have to cut pictures of different sizes and colors, and also have left and right spacing, which is more troublesome. The following method is to customize the control, which is good and bad.
2 method of using custom control
2.1 myprocesstest. XML file
Here's com example. Progresstest is the package name where hezaiprogress is located, and hezaiprogress is the custom control code.
2.2 HezaiProgress. Java file
Detailed comments are made in the code, which is not discussed here.
2.3 ProcessTest. java
What's better than the first method is that you can change the height, width, interval width, progress color, etc. at will, and only need one sentence of code, because it has been encapsulated in the front, but it seems to consume more memory.
Here is the screenshot after changing the color, which is the first picture of this blog:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.