中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Android游戲閃屏實(shí)現(xiàn)步驟詳解

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

下面是我總結(jié)的Android閃屏的經(jīng)驗(yàn),供大家參考,以下代碼,可以直接粘貼,稍作修改就好

1.導(dǎo)入一張圖片,我起名叫sp.png

2.在res/layout目錄下創(chuàng)建splashy.xml加入如下代碼:

<?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:orientation="vertical" >


    <ImageView
        android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/sp" />


</LinearLayout>

3.創(chuàng)建一個(gè)名為SplashyDemo.java的類,加入如下代碼:

package com.example.splashydemo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class SplashyDemo extends Activity {
private long splashyTime = 3000;//閃屏停留時(shí)間
private boolean isStop =false;//閃屏?xí)和?br /> private boolean isActivity = true;//是否跳過閃屏直接進(jìn)入主Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);// 隱藏標(biāo)題
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);// 設(shè)置全屏

setContentView(R.layout.splashy);

Thread splashyThread = new Thread()
{
public void run()
{
try {
long ms = 0;
while(isActivity && ms <splashyTime)
{
sleep(100);
if(!isStop)
{
ms+=100;
}
Log.i("TAG",ms+"");
}

//加入此 會(huì)去配置文件AndroidManifest.xml找對(duì)應(yīng)的com.google.app.splashy.CLEARSPLASH,有此標(biāo)識(shí)的Activity是閃屏后切換的界面
startActivity(new Intent("com.google.app.splashy.CLEARSPLASH"));

} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
                   finish();
               }
}
};
splashyThread.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
isStop = true;
}
@Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
isStop = false;
}
}

4.在AndroidManifest.xml文件中進(jìn)行配置

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity

//這里是我的主Activity的路徑
            android:name="com.example.splashydemo.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                 <action android:name="com.google.app.splashy.CLEARSPLASH"></action>
                 <category android:name="android.intent.category.DEFAULT"></category>
                 </intent-filter>
        </activity>
         <activity

//這里是閃屏文件的路徑
            android:name="com.example.splashydemo.SplashyDemo"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

標(biāo)簽: Google 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Android內(nèi)存檢測(cè)實(shí)現(xiàn)

下一篇:用PHP批量生成圖片縮略圖