zoukankan      html  css  js  c++  java
  • 在Android中创建启动界面 编辑

    1、制作一张启动图片splash.png,放置在res->drawable-hdpi文件夹中。

      2、新建布局文件splash.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:gravity="bottom|center" android:orientation="vertical"

      android:background="@drawable/splash">

      < TextView android:text="@+id/TextView01" android:layout_width="wrap_content"

      android:layout_height="wrap_content" android:layout_marginTop="20dip"

      android:typeface="sans" android:shadowDx="0" android:shadowDy="2"

      android:shadowRadius="1" android:shadowColor="#FFFFFF"

      android:textColor="#444444" android:textSize="20dip" android:id="@+id/versionNumber"

      android:gravity="bottom">

      < /TextView>

      < /LinearLayout>

      这里我们把上一步制作的图片作为启动界面的背景图,然后在界面底部显示当前程序的版本号。

      3、新建SplashActivity,在Oncreate中添加以下代码://http://www.my400800.cn

      setContentView(R.layout.splash);

      PackageManager pm = getPackageManager();

      try {

      PackageInfo pi = pm.getPackageInfo("com.lyt.android", 0);

      TextView versionNumber = (TextView) findViewById(R.id.versionNumber);

      versionNumber.setText("Version " + pi.versionName);

      } catch (NameNotFoundException e) {

      e.printStackTrace();

      }

      new Handler().postDelayed(new Runnable(){

      @Override

      public void run() {

      Intent intent = new Intent(SplashActivity.this,SplashScreenActivity.class);

      startActivity(intent);

      SplashActivity.this.finish();

      }

      }, 2500);

      4、 修改Manifest文件,将启动界面Activity改为默认启动,并且设置标题栏不可见。

      < ?xml version="1.0" encoding="utf-8"?>

    < manifest xmlns:android="http://schemas.android.com/apk/res/android"

      package="com.lyt.android" android:versionCode="1" android:versionName="1.0">

      < application android:icon="@drawable/icon" android:label="@string/app_name">

      < activity android:name=".SplashActivity" android:label="@string/app_name"

      android:theme="@android:style/Theme.NoTitleBar">

      < intent-filter>

      < action android:name="android.intent.action.MAIN" />

      < category android:name="android.intent.category.LAUNCHER" />

      < /intent-filter>

      < /activity>

      < activity android:name=".SplashScreenActivity" android:label="@string/app_name" >

      < /activity>

      < /application>

      < uses-sdk android:minSdkVersion="8" />

      < /manifest>

      5、显示效果如下:

  • 相关阅读:
    内存堆与栈的区别
    深度理解相对路径和绝对路径
    INFO:InstallAnywhere的Enterprise版本和Standard版本的主要区别
    HOWTO:InstallShield中如何调用批处理文件
    HOWTO:InstallScript工程中如何在用户协议界面中默认为接受协议
    HOWTO:InstallShield中如何通过脚本获取“My Documents”路径
    INFO:InstallShield工程中关于.NET依赖项的编译扫描警告
    InstallShield Kevin Wan博客文章索引列表(001~100)
    HOWTO:在InstallShield脚本中打开一个URL链接
    INFO:在InstallShield中修改安装包压缩.cab包的大小
  • 原文地址:https://www.cnblogs.com/jishu/p/2211136.html
Copyright © 2011-2022 走看看