第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android截屏表面視圖顯示黑屏

Android截屏表面視圖顯示黑屏

慕森王 2019-07-01 10:29:56
Android截屏表面視圖顯示黑屏我試圖通過代碼拍攝我的游戲的截圖,并通過一個意圖來分享它。我能做這些事情,但是截圖總是看起來是黑色的。下面是與分享截圖相關(guān)的代碼:View view = MainActivity.getView();view.setDrawingCacheEnabled(true);Bitmap screen = Bitmap.createBitmap(view.getDrawingCache(true));.. save Bitmap這是MainActivity中的內(nèi)容:view = new GameView(this);view.setLayoutParams(new RelativeLayout.LayoutParams(             RelativeLayout.LayoutParams.FILL_PARENT,             RelativeLayout.LayoutParams.FILL_PARENT));public static SurfaceView getView() {     return view;}以及視圖本身:public class GameView extends SurfaceView implements SurfaceHolder.Callback {private static SurfaceHolder surfaceHolder;...etc我就是這樣畫所有東西的:Canvas canvas = surfaceHolder.lockCanvas(null);         if (canvas != null) {                 Game.draw(canvas);...好的,基于一些答案,我構(gòu)建了:public static void share() {     Bitmap screen = GameView.SavePixels(0, 0, Screen.width, Screen.height);     Calendar c = Calendar.getInstance();     Date d = c.getTime();     String path = Images.Media.insertImage(             Game.context.getContentResolver(), screen, "screenShotBJ" + d                    + ".png", null);     System.out.println(path + " PATH");     Uri screenshotUri = Uri.parse(path);     final Intent emailIntent = new Intent(             android.content.Intent.ACTION_SEND);     emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);     emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);     emailIntent.setType("image/png");     Game.context.startActivity(Intent.createChooser(emailIntent,             "Share High Score:"));}鏡頭仍然是黑色的。我拯救它的方式有什么問題嗎?我嘗試過幾種不同的方法來獲取屏幕快照,但是沒有一種方法起作用:上面代碼中顯示的方法是最常用的方法。但這似乎行不通。這是使用SurfaceView的問題嗎?如果是這樣的話,如果我不能使用它,為什么view.getDrawinCache(True)還存在,以及如何解決這個問題?謝謝。
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 2366 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號