zoukankan      html  css  js  c++  java
  • Loading Image

    Android doesn’t handle animated gifs, but here’s one way to display an animated loading image that is similar to the Spinner style of ProgressDialog.

     

    Image Files:

    Loading Images

    drawable/loading.xml

    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item android:drawable="@drawable/loading_1" android:duration="100" />
    <item android:drawable="@drawable/loading_2" android:duration="100" />
    <item android:drawable="@drawable/loading_3" android:duration="100" />
    <item android:drawable="@drawable/loading_4" android:duration="100" />
    <item android:drawable="@drawable/loading_5" android:duration="100" />
    <item android:drawable="@drawable/loading_6" android:duration="100" />
    <item android:drawable="@drawable/loading_7" android:duration="100" />
    <item android:drawable="@drawable/loading_8" android:duration="100" />
    <item android:drawable="@drawable/loading_9" android:duration="100" />
    <item android:drawable="@drawable/loading_10" android:duration="100" />
    <item android:drawable="@drawable/loading_11" android:duration="100" />
    <item android:drawable="@drawable/loading_12" android:duration="100" />
    </animation-list>

    MyActivity.java

    import android.app.Activity;
    import android.graphics.drawable.AnimationDrawable;
    import android.os.Bundle;
    import android.widget.ImageView;
    import android.widget.LinearLayout;

     

    public class MyActivity extends Activity {

    ImageView loading;
    AnimationDrawable loadAnimation;

    public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    LinearLayout main = new LinearLayout(this);
    main.setOrientation(LinearLayout.VERTICAL);
    setContentView(main);

    loading = new ImageView(this);
    loading.setImageResource(R.drawable.loading);
    loadAnimation = (AnimationDrawable)loading.getDrawable();
    main.addView(loading);

    }

     

    //can't start animating in OnCreate, so start when window becomes in focus
    @Override
    public void onWindowFocusChanged(boolean hasFocus){

    loadAnimation.start();

    }

    }

  • 相关阅读:
    C# 6.0 新特征 Demo
    SmartGit 试用过期
    .net版Git Server --- bonobo
    线程操作若干(复习)
    异步的两种写法: async 与 BeginInvoke
    winform 防止主界面卡死
    wcf 出现 IsContentTypeSupported 错误
    NodeJs 实时压缩 项目js文件
    Excel 公式(细节若干)
    itextSharp 对pdf的每个页面添加footer/header
  • 原文地址:https://www.cnblogs.com/fx2008/p/3141382.html
Copyright © 2011-2022 走看看