小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

創(chuàng)建Android啟動(dòng)界面

 漢江秋月夜 2014-01-16

創(chuàng)建Android啟動(dòng)界面

每個(gè)Android應(yīng)用啟動(dòng)之后都會(huì)出現(xiàn)一個(gè)Splash啟動(dòng)界面,顯示產(chǎn)品的LOGO、公司的LOGO或者開(kāi)發(fā)者信息。如果應(yīng)用程序啟動(dòng)時(shí)間比較長(zhǎng),那么啟動(dòng)界面就是一個(gè)很好的東西,可以讓用戶耐心等待這段枯燥的時(shí)間。

  • 制作Splash界面
    突出產(chǎn)品LOGO,產(chǎn)品名稱(chēng),產(chǎn)品主要特色;
    注明產(chǎn)品的版本信息;
    注明公司信息或者開(kāi)發(fā)者信息;
    背景圖片,亦可以用背景顏色代替;

  • 除了等待還能做點(diǎn)什么
    大多數(shù)的Splash界面都是會(huì)等待一定時(shí)間,然后切換到下一個(gè)界面;
    其實(shí),在這段時(shí)間里,可以對(duì)系統(tǒng)狀況進(jìn)行檢測(cè),比如網(wǎng)絡(luò)是否通,電源是否充足;
    或者,預(yù)先加載相關(guān)數(shù)據(jù);
    為了能讓啟動(dòng)界面展現(xiàn)時(shí)間固定,需要計(jì)算執(zhí)行以上預(yù)處理任務(wù)所花費(fèi)的時(shí)間,那么:?jiǎn)?dòng)界面SLEEP的時(shí)間=固定時(shí)間-預(yù)處理任務(wù)時(shí)間

  • 源碼示例(以Wordpress的Android客戶端為例)
    AndroidMenifest.xml
    復(fù)制代碼
    <activity android:icon="@drawable/app_icon"
    android:screenOrientation
    ="portrait"
    android:name
    =".splashScreen"
    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>
    復(fù)制代碼
    splashScreen.java
    復(fù)制代碼
    package org.wordpress.android;

    import android.app.Activity;
    import android.content.Intent;
    import android.content.pm.PackageInfo;
    import android.content.pm.PackageManager;
    import android.content.pm.PackageManager.NameNotFoundException;
    import android.graphics.PixelFormat;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.WindowManager;
    import android.widget.TextView;


    public class splashScreen extends Activity {
    /**
    * Called when the activity is first created.
    */

    @Override
    public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getWindow().setFormat(PixelFormat.RGBA_8888);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);

    setContentView(R.layout.splashscreen);

    //Display the current version number
    PackageManager pm = getPackageManager();
    try {
    PackageInfo pi
    = pm.getPackageInfo("org.wordpress.android", 0);
    TextView versionNumber
    = (TextView) findViewById(R.id.versionNumber);
    versionNumber.setText(
    "Version " + pi.versionName);
    }
    catch (NameNotFoundException e) {
    e.printStackTrace();
    }

    new Handler().postDelayed(new Runnable() {
    public void run() {
    /* Create an Intent that will start the Main WordPress Activity. */
    Intent mainIntent
    = new Intent(splashScreen.this, wpAndroid.class);
    splashScreen.
    this.startActivity(mainIntent);
    splashScreen.
    this.finish();
    }
    },
    2900); //2900 for release

    }
    }
    復(fù)制代碼
    splashscreen.xml
    復(fù)制代碼
    <!--
    android:gravity是對(duì)元素本身說(shuō)的,元素本身的文本顯示在什么地方靠著換個(gè)屬性設(shè)置,不過(guò)不設(shè)置默認(rèn)是在左側(cè)的。
    android:layout_gravity是相對(duì)與它的父元素說(shuō)的,說(shuō)明元素顯示在父元素的什么位置
    -->
    <LinearLayout android:id="@+id/LinearLayout01"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="fill_parent"
    xmlns:android
    ="http://schemas./apk/res/android"
    android:gravity
    ="center|center"
    android:background
    ="@drawable/home_gradient"
    android:orientation
    ="vertical">
    <!--
    android:scaleType是控制圖片如何resized/moved來(lái)匹對(duì)ImageView的size
    CENTER_INSIDE / centerInside 將圖片的內(nèi)容完整居中顯示,通過(guò)按比例縮小或原來(lái)的size使得圖片長(zhǎng)/寬等于或小于View的長(zhǎng)/寬
    -->
    <ImageView android:layout_marginTop="-60dip"
    android:paddingLeft
    ="20dip"
    android:paddingRight
    ="20dip"
    android:scaleType
    ="centerInside"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:id
    ="@+id/wordpress_logo"
    android:src
    ="@drawable/wordpress_home">
    </ImageView>
    <!--
    android:typeface 字體風(fēng)格
    -->
    <TextView android:text="@+id/TextView01"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:layout_marginTop
    ="20dip"
    android:typeface
    ="serif"
    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>
    復(fù)制代碼
標(biāo)簽: Splash, Android
3
0
(請(qǐng)您對(duì)文章做出評(píng)價(jià))
下一篇:在android.app.Application中定義全局變量

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多