您的位置:首页 > 移动开发 > Android开发

(Touch Android) 新浪微博Android客户端开发第一篇:Logo 页面的实现

2011-09-26 19:26 531 查看
这是一个简单的Logo页面。功能也就是展示一下Logo而已

。先看一下页面效果吧。



先说一下页面布局:有一个绿色的背景,正中间有一个新浪的Logo图标。这个Logo会由浅入深的一个动画变化。动画结束后会跳转到登陆页面。

下面我们就先看布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg"
android:gravity="center"
>

<ImageView android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo_bg"/>

</LinearLayout>


以上就是布局文件的代码,相当相当的简单。

继续看Java代码

package com.droidstouch.iweibo.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

import com.droidstouch.iweibo.R;

public class LogoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//设置全屏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.logo);

AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(3000);

ImageView img_logo = (ImageView) this.findViewById(R.id.img_logo);
img_logo.setAnimation(animation);

animation.setAnimationListener(new AnimationListener(){

public void onAnimationEnd(Animation animation)
{

Intent intent = new Intent(LogoActivity.this, LoginActivity.class);
startActivity(intent);
}

public void onAnimationRepeat(Animation animation)
{
// TODO Auto-generated method stub

}

public void onAnimationStart(Animation animation)
{
// TODO Auto-generated method stub

}});

}
}


Java代码中呢,用到了两个知识点。可以参考(Android全屏设置的两种方式)和(android Animation 动画效果介绍
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: