Tutorial vidio pengaplikasian bisa lihat dibawah ini.import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.view.SurfaceHolder; import android.view.SurfaceView; public class Gameplay extends SurfaceView { private Bitmap gambar; private SurfaceHolder holder; public Gameplay(Context context){ super(context); holder = getHolder(); holder.addCallback(new SurfaceHolder.Callback2() { @SuppressLint("WrongCall") @Override public void surfaceCreated(SurfaceHolder holder) { Canvas canvas = holder.lockCanvas(null); onDraw (canvas); holder.unlockCanvasAndPost(canvas); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } @Override public void surfaceDestroyed(SurfaceHolder holder) { } @Override public void surfaceRedrawNeeded(SurfaceHolder holder) { } }); gambar = BitmapFactory.decodeResource(getResources(),//letakgambaryanginginditayangkan//); } @Override protected void onDraw (Canvas canvas){ canvas.drawColor(Color.BLACK); canvas.drawBitmap(gambar,10,10,null); } }
Sekian selamat mencoba.
0 Response to "Android Studio Showing Image Script"
Post a Comment