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

来源:互联网 发布:linux mysql 安装 编辑:程序博客网 时间:2024/06/16 09:05

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

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

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

<?xml version="1.0" encoding="UTF-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_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>

  接下来为Logo动画

package haiyang.project.iweibo;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.*;import android.view.animation.*;import android.view.animation.Animation.AnimationListener;import android.widget.ImageView;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);                ImageView imageLogo=(ImageView) this.findViewById(R.id.img_logo);                AlphaAnimation animation=new AlphaAnimation(0.0f, 1.0f);//跳转动画,从完全透明到完全不透明        animation.setDuration(3000);//动画持续的时间        animation.setAnimationListener(new AnimationListener() {@Overridepublic void onAnimationStart(Animation animation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationRepeat(Animation animation) {// TODO Auto-generated method stub}//在Logo动画完成时,跳转到登录界面@Overridepublic void onAnimationEnd(Animation animation) {// TODO Auto-generated method stubIntent intent=new Intent(LogoActivity.this,LoginActivity.class);//从Logo页面跳到登录页面        startActivity(intent);}});        imageLogo.setAnimation(animation);    }}

    补充:

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

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

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

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

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

②在 AndroidManifest.xml 使用:

<activity android:name=".LoginActivity"  android:theme="@style/theme_fullScreen"/>

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

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

package haiyang.project.iweibo;import android.app.Activity;import android.os.Bundle;public class LoginActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);this.setContentView(R.layout.main);}}

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

                           此视频资料来自:http://bbs.droidstouch.com/forum-53-1.html  有兴趣的可以一起去学习。