Egret打包App 短暫黑屏解決方案 (Egret4.1.0)

來源:互聯網
上載者:User

標籤:get   png   說明   this   lint   one   raw   控制項   set   

 

論壇已經有人解決:http://bbs.egret.com/forum.php?mod=viewthread&tid=30288&highlight=app%2B%E9%BB%91%E5%B1%8F

 

這裡詳細說明下

 

顯示和移除圖片的代碼如下:

import android.app.ActionBar.LayoutParams;import android.widget.ImageView;
    //啟動遊戲,解決黑屏,頂層顯示的圖片    private LayoutParams params;    private ImageView image;    public void startGame(){        params = new LayoutParams(LayoutParams.WRAP_CONTENT,        LayoutParams.WRAP_CONTENT);            //設定中間位置            params.gravity = Gravity.TOP|Gravity.LEFT|Gravity.BOTTOM|Gravity.RIGHT;            image = new ImageView(this);        image.setScaleType(ImageView.ScaleType. CENTER_CROP);        image.setImageResource(R.drawable.start_screen);        //添加控制項            addContentView(image, params);    }        //遊戲啟動後,隱藏頂層顯示的圖片    public void gameStartEnd(){        image.setVisibility(View.GONE);    }

 

頂層顯示的圖片可以放在res->drawable檔案夾下,我這裡使用的博雅的啟動圖片。放在res下的圖片才能在代碼裡使用R.drawable調用。

 

 

這段代碼粘貼在主檔案裡,我這裡是testapp.java

 

在onCreate裡調用startGame

 

 

 在Egret啟動完成後,使用ExternalInterface通知Native移除圖片

 

Native收到Egret的啟動完成資訊,則調用gameStartEnd移除圖片

 

Egret打包App 短暫黑屏解決方案 (Egret4.1.0)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.