实现图片淡入效果

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_ling" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/welcome" />

    <TextView
        android:id="@+id/compete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />
    <ProgressBar android:id="@+id/prograssBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@android:attr/progressBarStyle"
        android:visibility="gone"
        android:layout_above="@id/compete"
        android:layout_centerHorizontal="true"/>

</RelativeLayout>

package cn.bzu.alphaanimation;


import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.ProgressBar;


public class AlphaAnimationActivity extends Activity {
	private ProgressBar progressBar;
	private ImageView image;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alpha_animation);
        progressBar=(ProgressBar) this.findViewById(R.id.prograssBar);
        image=(ImageView) this.findViewById(R.id.image);
        progressBar.setVisibility(View.VISIBLE);
        //创建一个淡入效果的Animation对象
        AlphaAnimation animation=new AlphaAnimation(0.0f, 0.1f);
        animation.setDuration(1000);
        animation.setStartOffset(500);
        image.setAnimation(animation);
        new Handler().postDelayed(new Runnable() {
			// 新建一个handler实现演示跳转
			@Override
			public void run() {
				Intent intent= new Intent();
				intent.setClass(AlphaAnimationActivity.this, MainActivity.class);
				startActivity(intent);
				
			}
		}, 1500);
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_alpha_animation, menu);
        return true;
    }

    
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值