淘宝Android客户端 dialog

淘宝Android客户端 dialog_第1张图片


去年刚开始工作的时候,组长让我研究下dialog,我说淘宝的不错,然后啊 就找各种资料,查 ,结果了网上都说是重写dialog了,而那时根本就没有能力写了,结果了那项目还是用系统的progressdialog了,

下午么事,突然想起曾经的dialog,思考下,反编译了下淘宝的源码,一看居然是2张图片,立即想到是用动画实现了,想起曾经的种种,真是好玩啊,从中想明白一个道理,当我们看到某个app有好的特效时,先反编译下它的源码,大概可以看出它是怎么实现的,然后在去网上搜索一下,那样思路就出来了。


anmins.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >


    <rotate
        android:duration="800"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="infinite"
        android:repeatMode="restart"
        android:toDegrees="360" />


</set>

main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="vertical" >


    <RelativeLayout
        android:id="@+id/view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#ffffff"
        android:visibility="gone" >


        <ImageView
            android:id="@+id/tb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/loading"
            android:contentDescription="@string/desc" />


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/desc"
            android:src="@drawable/load_bk" />
    </RelativeLayout>


</RelativeLayout>



MainActivity.java


package com.xzq.taobao;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;


public class MainActivity extends Activity {


    private ImageView tb;
    private RelativeLayout view;
    private Animation rotateAnimation; // 加载圈圈的动画


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);


        view = (RelativeLayout) findViewById(R.id.view);
        tb = (ImageView) findViewById(R.id.tb);
        view.setVisibility(View.VISIBLE);
        rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.anmins);
        rotateAnimation.setInterpolator(new LinearInterpolator());
        tb.setAnimation(rotateAnimation);
    }
}





你可能感兴趣的:(android,layout,Class,animation,dialog,encoding)