Android中Market的Loading效果實(shí)現(xiàn)方法
本文實(shí)例講述了Android中Market的Loading效果實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:
在Android中,要實(shí)現(xiàn)Loading效果,一般情況下都使用ProgressDialog控件。ApiDemos/src/com/example/android/apis/view/ProgressBar3.java 提供兩個(gè)demo:
仔細(xì)看了Android Market,發(fā)現(xiàn)卻是不一樣的,請(qǐng)看截圖:
那到底如何實(shí)現(xiàn)呢?首先,我們創(chuàng)建一個(gè)布局文件,
res/layout/fullscreen_loading_indicator.xml, 其內(nèi)容如下:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center_vertical|center_horizontal" android:orientation="horizontal" android:id="@+id/fullscreen_loading_style" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ProgressBar android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleSmall" /> <TextView android:id="@+id/current_action" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5.0dip" android:text="@+string/loading" /> </LinearLayout>
然后在main.xml 把它include 進(jìn)來(lái)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:id="@+id/main_info" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="abc"></TextView> </LinearLayout> <LinearLayout android:orientation="vertical" android:id="@+id/main_Loading" android:layout_width="fill_parent" android:layout_height="fill_parent"> <include android:visibility="visible" android:layout_width="fill_parent" android:layout_height="fill_parent" layout="@layout/fullscreen_loading_style" /> </LinearLayout> </LinearLayout>
主程序:
package com.tymx.fullloading; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.LinearLayout; public class myFullLoading extends Activity { /** Called when the activity is first created. */ private LinearLayout mLoadingLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); if (msg.what==1){ mLoadingLayout = (LinearLayout)findViewById(R.id.fullscreen_loading_style); mLoadingLayout.setVisibility(View.GONE); LinearLayout mMain = (LinearLayout)findViewById(R.id.main_info); mMain.setVisibility(View.VISIBLE); } } }; new Thread(){ public void run(){ for (int i=0;i<1000;i++){ System.out.print(i+""); } Message msg = handler.obtainMessage(1,"flash"); handler.sendMessage(msg); } }.start(); } }
運(yùn)行的效果為:
希望本文所述對(duì)大家的Android程序設(shè)計(jì)有所幫助。
- 三款A(yù)ndroid炫酷Loading動(dòng)畫(huà)組件推薦
- 一看就喜歡的loading動(dòng)畫(huà)效果Android分析實(shí)現(xiàn)
- Android自定義加載loading view動(dòng)畫(huà)組件
- Android項(xiàng)目實(shí)戰(zhàn)手把手教你畫(huà)圓形水波紋loadingview
- Android實(shí)現(xiàn)創(chuàng)意LoadingView動(dòng)畫(huà)效果
- Android自定義View實(shí)現(xiàn)loading動(dòng)畫(huà)加載效果
- Android Studio卡很久(loading)的問(wèn)題解決辦法
- Android 自定義通用的loadingview實(shí)現(xiàn)代碼
- Android自定義環(huán)形LoadingView效果
- Android實(shí)現(xiàn)一個(gè)帶粘連效果的LoadingBar
相關(guān)文章
Core Animation一些Demo總結(jié) (動(dòng)態(tài)切換圖片、大轉(zhuǎn)盤(pán)、圖片折疊、進(jìn)度條等動(dòng)畫(huà)效果)
這篇文章主要介紹了Core Animation一些Demo總結(jié) (動(dòng)態(tài)切換圖片、大轉(zhuǎn)盤(pán)、圖片折疊、進(jìn)度條等動(dòng)畫(huà)效果)的相關(guān)資料,需要的朋友可以參考下2016-02-02android表格效果之ListView隔行變色實(shí)現(xiàn)代碼
首先繼承SimpleAdapter再使用重載的Adapter來(lái)達(dá)到效果,其實(shí)主要是需要重載SimpleAdapter,感興趣的朋友可以研究下,希望本文可以幫助到你2013-02-02Android 使用VideoView播放MP4的簡(jiǎn)單實(shí)現(xiàn)
這篇文章主要介紹了Android 使用VideoView播放MP4的簡(jiǎn)單實(shí)現(xiàn),實(shí)現(xiàn)簡(jiǎn)單的播放功能,播放手機(jī)本地的MP4文件,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-05-05android開(kāi)發(fā)教程之實(shí)現(xiàn)滑動(dòng)關(guān)閉fragment示例
這篇文章主要介紹了android實(shí)現(xiàn)滑動(dòng)關(guān)閉fragment示例,需要的朋友可以參考下2014-03-03Android使用AsyncQueryHandler實(shí)現(xiàn)獲取手機(jī)聯(lián)系人功能
這篇文章主要為大家詳細(xì)介紹了Android使用AsyncQueryHandler實(shí)現(xiàn)獲取手機(jī)聯(lián)系人功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能
DrawerLayout組件同樣是V4包中的組件,也是直接繼承于ViewGroup類(lèi),所以說(shuō)是一個(gè)容器類(lèi),下面通過(guò)本文給大家介紹使用DrawerLayout組件實(shí)現(xiàn)側(cè)滑抽屜的功能,感興趣的朋友一起看下吧2016-08-08Android開(kāi)發(fā)手冊(cè)TextView屬性實(shí)現(xiàn)效果盤(pán)點(diǎn)
這篇文章主要為大家介紹了Android開(kāi)發(fā)手冊(cè)TextView屬性實(shí)現(xiàn)的效果盤(pán)點(diǎn)及使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06打飛機(jī)游戲終極BOSS Android實(shí)戰(zhàn)打飛機(jī)游戲完結(jié)篇
打飛機(jī)游戲終極BOSS,Android實(shí)戰(zhàn)打飛機(jī)游戲完結(jié)篇,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07