Android新浪微博客户端的logo界面

为了简化步骤,这一步只需要一张logo,颜色渐深,三秒显示后跳入下一个activity,同时去掉标题栏与状态栏。代码如下:logo.java中

package com.ding.ui;

import weibo4j.Weibo;
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;

public class logo extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// 取消标题栏(也可以在manifest里面配置)
// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// 取消状态栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.log);

// 三秒钟之后进入login
ImageView iv = (ImageView) this.findViewById(R.id.logo_bg);
// 从浅到深,从百分之10到百分之百
AlphaAnimation aa = new AlphaAnimation(0.1f, 1.0f);
aa.setDuration(3000);
iv.setAnimation(aa);

// 给aa设置监听器
aa.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
System.setProperty("weibo4j.oauth.consumerKey",
Weibo.CONSUMER_KEY);
System.setProperty("weibo4j.oauth.consumerSecret",
Weibo.CONSUMER_SECRET);
// 三秒之后跳出
Intent it = new Intent(logo.this, Login.class);
startActivity(it);
// 三秒之后 这个窗口就没用了 应该finish
finish();
}
});
}
}

由于本客户端采用oauth认证方式,在这一步跳转到下一个activity之前,将CONSUMER_KEY与CONSUMER_SECRET存入系统中,在下一章中将主要说明新浪微博的oauth认证


log.xml中代码为:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation
="vertical"
android:gravity
="center"
android:layout_width
="fill_parent"
android:layout_height
="fill_parent"
android:background
="#ffffff"
>
<ImageView
android:id="@+id/logo_bg"
android:src
="@drawable/logo_bg"
android:layout_width
="wrap_content"
android:layout_height
="wrap_content"
/>
</LinearLayout>


Manifest中配置为:

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
<activity android:name=".logo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Login"></activity>
</application>


这里android:theme="@android:style/Theme.NoTitleBar"这一段代码可实现整个应用程序无标题栏。而不用在每个activity中都进行配置。

posted on 2011-09-25 17:14  Arsure  阅读(747)  评论(0编辑  收藏  举报