Android custom load style picture of the specific implementation _android

Source: Internet
Author: User
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.
Related Article

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.