Buffer progress bar or loading progress bar, buffer progress bar Loading

Source: Internet
Author: User

Buffer progress bar or loading progress bar, buffer progress bar Loading

Buffering progress bars or loading progress bars. During page or video loading, in order to better experience interaction between the UI and App functions, these buffering loading wait effects are essential;

Let's take a look at the animation effect of rotation: So their specific source code is here: loading_1:

<?xml version="1.0" encoding="utf-8"?><rotate     xmlns:android="http://schemas.android.com/apk/res/android"    android:fromDegrees="0"    android:pivotX="50%"    android:pivotY="50%"    android:toDegrees="1080.0" >    <shape        android:innerRadiusRatio="3"        android:shape="ring"        android:thicknessRatio="8"        android:useLevel="false" >        <gradient            android:centerColor="#FFDC35"            android:centerY="0.50"            android:endColor="#CE0000"            android:startColor="#FFFFFF"            android:type="sweep"            android:useLevel="false" />    </shape></rotate>

Loading_2:
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <item >        <rotate            android:drawable="@drawable/movie_loading"            android:fromDegrees="0.0"            android:pivotX="50.0%"            android:pivotY="50.0%"            android:toDegrees="1080.0" />    </item></layer-list>
Loading_3:
<?xml version="1.0" encoding="UTF-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android"    android:oneshot="false" >    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_01"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_02"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_03"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_04"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_05"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_06"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_07"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_08"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_09"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_10"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_11"            android:gravity="left" />    </item>    <item android:duration="150">        <clip            android:clipOrientation="horizontal"            android:drawable="@drawable/loading_12"            android:gravity="left" />    </item></animation-list>

Activity_main.java:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="horizontal"    android:gravity="center_horizontal"    android:background="#222222">    <ProgressBar        android:id="@+id/loading_1"        android:layout_width="50dp"        android:layout_height="50dp"        android:layout_marginTop="60dp"        android:indeterminate="false"        android:padding="5dp"        android:indeterminateDrawable="@drawable/loading_1" />    <ProgressBar        android:id="@+id/loading_2"        android:layout_width="50dp"        android:layout_height="50dp"        android:layout_marginTop="60dp"        android:indeterminate="false"        android:padding="5dp"        android:indeterminateDrawable="@drawable/loading_2" />    <ProgressBar        android:id="@+id/loading_3"        android:layout_width="50dp"        android:layout_height="50dp"        android:indeterminate="false"        android:layout_marginTop="60dp"        android:padding="5dp"        android:indeterminateDrawable="@drawable/loading_3" /></LinearLayout>
You do not need to add any code in Activity. java!

...



Why do I always watch the video and load the progress bar when I check it?

Because loading the video screen does not mean continuous loading, he will choose to attach multiple resources first. Therefore, it may have been loaded before, and a section in the middle is not loaded before it is loaded later. Sometimes there are only a small segment but few resources, so it takes a long time to load it ~ So you can let him load it for a while before seeing it, so that it won't take a while.
 
How to make a progress bar when there is a large flash file webpage buffer?

Make a swf separately and make a progress bar in it. The Code is as follows:
My_mcl_main = new movi1_loader ();
MyListener_main = new Object ();
MyListener_main.onLoadStart = function (target_mc)
{
Loading. _ visible = true; // the visibility of the progress bar, which is displayed when a video is loaded.
};
MyListener_main.onLoadProgress = function (target_mc, loadedBytes, totalBytes)
{
Loadtotal = Math. ceil (loadedBytes/totalBytes * 100 );
Loading. gotoAndStop (loadtotal); // loading is the Instance name of your progress bar. 100 frames in total.
Loading.txt = "downloaded:" + loadtotal + "%"; // displays the percentage.
};
MyListener_main.onLoadComplete = function (target_mc)
{
Loading. _ visible = false; // the visibility of the progress bar. If the video is loaded, it is hidden.
};
MyListener_main.onLoadInit = function (target_mc)
{
Mcload. gotoAndStop (2); // This is generally used for loading. The first frame of your album is blank, and you can add stop to make the second frame have content. The same is true for mcload. gotoAndPlay (2), but you need to add another stop in your album.
};
MyListener_main.onLoadError = function (target_mc, errorCode)
{
Trace ("********** the file is not fully loaded *********");
};
My_mcl_main.addListener (myListener_main );
My_mcl_main.loadClip ("album .swf", mcload); // mcload is the name of the video editing instance used to store the album after the album is loaded. The file to be loaded must be in English, not Chinese!

PS: In this case, the swf you used to load is only a few K and will be displayed on the webpage soon. If your webpage background is not white, such as black or other dark colors, adding <param name = "wmode" value = "transparent"/> in HTML will make swf transparent, in this way, no one else can see the white area. Please HI me.
Reference: www. dolphinhao. tk/

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.