Let's take a look at the effect chart first, I believe many Android beginners want to know how the effect is achieved, to the above figure:
To implement the custom load style in this figure above, it is very simple, first of all we need the layout components have Processbar and TextView, the following is the layout file code (just the layout of the loaded page):
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Horizontal"
android:gravity= "Center" >
<progressbar
Android:id= "@+id/progressbar1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
style= "@style/process_bar_style"/>
<textview
Android:id= "@+id/processhint"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_marginleft= "10DP"
android:text= "@string/prohint"
Android:textsize= "18sp"/>
</LinearLayout>
Because the use of this page is very high, so we separate it out as an XML file, in Android if you want to introduce other layout files in the layout file, the method is in fact similar to the include in JSP programming, the specific format is as follows: <include Android:id= "@+id/layout_process" layout= "@layout/processbar"/>
Here we will say how to achieve the implementation of the rotation process, because the loaded style is not good-looking, we need a custom style, this time need a PNG picture, that is, the rotation of the progress bar.
Next we need to define the style file. Process_style.xml (defined under the Values folder)
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<resources xmlns:android= "Http://schemas.android.com/apk/res/android" >
<style name= "Process_bar_style" >
<item name= "android:indeterminatedrawable" > @drawable/processstyle</item>
</style>
</resources>
After the definition of the style file, of course, did not achieve the above effect, of course, we also want to let the pictures move, then we need to customize the properties of the animation ha, Process.xml, in the Drawable folder to define
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<animated-rotate xmlns:android= "Http://schemas.android.com/apk/res/android"
android:drawable= "@drawable/process"
android:pivotx= "50%"
Android:pivoty= "50%"
/>
The key is this code, you can achieve the automatic rotation of the picture.
So you can try it, and you can do the loading designer.