不知道为什么昨天发布的一篇博文没有显示出来,草稿箱都没有存档,只好重新写一篇。
介绍启动的logo页面和第一次使用时显示的导航页面。
logo页面的实现是采用新浪微博客户端开发教程里面的方法,一个背景图片,然后动画渐现一个logo图片。
public class LogoActivity extends Activity {
Intent intent = null;
/** 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.2f, 1.0f);
animation.setDuration(2000);//2S渐现
ImageView img_logo = (ImageView) this.findViewById(R.id.img_logo);
img_logo.setAnimation(animation);//将logo设置为动画显示
UserInfo loginUser = SharedPreferencesUtil.getLoginUser(LogoActivity.this);
boolean isUsed = SharedPreferencesUtil.getIsUsed(LogoActivity.this);
//判断是否使用过
if(isUsed){
//判断是否有自动登录用户
if(null == loginUser){//无自动登录用户则进入登录界面
intent = new Intent(LogoActivity.this,LoginActivity.class);
}else {//有自动登录用户则进入主界面
intent = new Intent(LogoActivity.this,HomeActivity.class);
}
}else {
intent = new Intent(LogoActivity.this,GuideActivity.class);
}
// intent = new Intent(LogoActivity.this, LoginActivity.class);
//动画监听
animation.setAnimationListener(new AnimationListener() {
//动画结束时跳转
public void onAnimationEnd(Animation animation) {
startActivity(intent);
LogoActivity.this.finish();
overridePendingTransition(SwitchActivityAnim.rightIn(),SwitchActivityAnim.rightOut());
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationStart(Animation arg0) {
startMainService();
}
});
}
// 启动主服务
private void startMainService(){
Intent service = new Intent(this, MainService.class);
startService(service);
}
}
界面文件
<?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/bg_logo"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
</LinearLayout>
现在先忽略所有的动画,后面会写一篇动画专题。
第一次启动时,logo动画完毕就会进入到导航页面。
导航页面是仿微信的导航页面,代码也是在网上找到的。
public class GuideActivity e