新浪微博Android客户端学习记录一:完成Logo界面

http://blog.csdn.net/yanghai0321/article/details/7525919

 前不久把《Android开发入门教程》看完,并手敲了大部分的示例代码,对android有了个初步的了解,于是在网上找了个不错的项目(新浪微博)开发视频,计划在在接下来的一个月内把这套视频学习完并做好笔记。

        第一个视频的任务是完成Logo界面。

        首先写一个logo.xml布局文件

[html]  view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <LinearLayout   
  3. xmlns:android="http://schemas.android.com/apk/res/android"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     android:background="@drawable/main_bg"  
  7.     android:gravity="center"  
  8.     >  
  9.       
  10.     <ImageView  
  11.     android:id="@+id/img_logo"  
  12.     android:layout_width="wrap_content"  
  13.     android:layout_height="wrap_content"  
  14.     android:src="@drawable/logo_bg"  
  15.     />  
  16.     </LinearLayout>  

  接下来为Logo动画

[java]  view plain copy
  1. package haiyang.project.iweibo;  
  2.   
  3. import android.app.Activity;  
  4. import android.content.Intent;  
  5. import android.os.Bundle;  
  6. import android.view.*;  
  7. import android.view.animation.*;  
  8. import android.view.animation.Animation.AnimationListener;  
  9. import android.widget.ImageView;  
  10.   
  11. public class LogoActivity extends Activity {  
  12.     /** Called when the activity is first created. */  
  13.     @Override  
  14.     public void onCreate(Bundle savedInstanceState) {  
  15.         super.onCreate(savedInstanceState);  
  16.           
  17.       //取消标题  
  18.         this.requestWindowFeature(Window.FEATURE_NO_TITLE);  
  19.         //取消状态栏  
  20.         this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  21.                         WindowManager.LayoutParams.FLAG_FULLSCREEN);  
  22.         //以上取消标题及取消状态栏需在此前完成,因为一旦调用此方法后就渲染完成,再无法改变  
  23.         setContentView(R.layout.logo);  
  24.           
  25.         ImageView imageLogo=(ImageView) this.findViewById(R.id.img_logo);  
  26.           
  27.         AlphaAnimation animation=new AlphaAnimation(0.0f, 1.0f);//跳转动画,从完全透明到完全不透明  
  28.         animation.setDuration(3000);//动画持续的时间  
  29.         animation.setAnimationListener(new AnimationListener() {  
  30.             @Override  
  31.             public void onAnimationStart(Animation animation) {  
  32.                 // TODO Auto-generated method stub  
  33.                   
  34.             }  
  35.             @Override  
  36.             public void onAnimationRepeat(Animation animation) {  
  37.                 // TODO Auto-generated method stub  
  38.                   
  39.             }  
  40.             //在Logo动画完成时,跳转到登录界面  
  41.             @Override  
  42.             public void onAnimationEnd(Animation animation) {  
  43.                 // TODO Auto-generated method stub  
  44.                 Intent intent=new Intent(LogoActivity.this,LoginActivity.class);  
  45.                 //从Logo页面跳到登录页面  
  46.                 startActivity(intent);  
  47.             }  
  48.         });  
  49.         imageLogo.setAnimation(animation);  
  50.     }  
  51. }  

    补充:

      关于android Animation动画效果介绍,更详细的内容可以参考:http://bbs.droidstouch.com/thread-56-1-1.html

     关于全屏的设置,Android 有两种方式:

     第一种方式:在protected void onCreate(Bundle savedInstanceState) 里面的this.setContentView() 之前加入以上代码中注释处的代码。

     第二种方式:
      ①在res/values 目录创建个theme.xml 文件(这个文件注主要用来放样式的),文件内容:

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>     
  3.         <!-- name 是Style的名称,parent 继承那个父类样式 -->  
  4.         <style name="theme_fullScreen" parent="android:Theme.Black">   
  5.             <item name="android:windowNoTitle">true</item>  <!-- 设置无标题 -->  
  6.             <item name="android:windowFullscreen">?android:windowNoTitle</item> <!-- 是否填充慢屏幕,引用android:windowNoTitle 的值 -->  
  7.    </style>     
  8. </resources>  

②在 AndroidManifest.xml 使用:

[html]  view plain copy
  1. <activity android:name=".LoginActivity"  android:theme="@style/theme_fullScreen"/>  

这样就可以完成Android的全屏设置。

     登录界面的操作(待后续学习)

[java]  view plain copy
  1. package haiyang.project.iweibo;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5.   
  6. public class LoginActivity extends Activity {  
  7.       
  8.     @Override  
  9.     protected void onCreate(Bundle savedInstanceState) {  
  10.         // TODO Auto-generated method stub  
  11.         super.onCreate(savedInstanceState);  
  12.         this.setContentView(R.layout.main);  
  13.     }  
  14. }  

    添加这个java文件时,注意要在AndroidManifest.xml中的<application    />下添加<activity android:name=".LoginActivity"/>   


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值