2
アプリケーションの起動時に空白の表示が表示されます。 XMLプレビューで何が表示されるべきかを知ることができますが、アプリケーションを起動したときにはただ白です。私はSurfaceViewの輪郭を見ることができますが、内容はありません。アプリケーションが起動されたときの空白の表示(SurfaceView)
私は自分自身を教えているので、基礎知識は限られており、回答を理解したいので、簡単な説明が大変ありがとう!
ありがとうございます - フレンチー。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.Frenchie.SurfaceView.MySurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0dip"
android:id="@+id/surfaceView"/>
</LinearLayout>
MainActivity
package com.Frenchie.SurfaceView;
import ...
public class MainActivity extends Activity {
com.Frenchie.Drawing.MySurfaceView surfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
surfaceView = findViewById(R.id.surfaceView);
}
}
MySurfaceView
package com.Frenchie.SurfaceView;
import ...
public class MySurfaceView extends SurfaceView implements Runnable {
private Bitmap bmp;
private SurfaceHolder holder;
public MySurfaceView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
holder = getHolder();
holder.addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
Canvas c = holder.lockCanvas(null);
draw(c);
holder.unlockCanvasAndPost(c);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format,
int width, int height) {
}
});
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.player);
}
@Override
public void draw(Canvas canvas) {
super.draw(canvas);
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(bmp, (MeasureSpec.getSize(getMeasuredWidth()) - bmp.getWidth())/2, (MeasureSpec.getSize(getMeasuredHeight()) - bmp.getHeight())/2, null);
}
@Override
public void run() {
//TODO movement here when display is working
}
}
Logcat
11-27 16:20:43.437 24092-24092/? I/zygote: Not late-enabling -Xcheck:jni (already on)
11-27 16:20:43.450 24092-24092/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
11-27 16:20:43.804 24092-24092/com.Frenchie.SurfaceView I/InstantRun: starting instant run server: is main process
11-27 16:20:43.948 24092-24110/com.Frenchie.SurfaceView D/OpenGLRenderer: HWUI GL Pipeline
[ 11-27 16:20:44.001 24092:24110 D/ ]
HostConnection::get() New Host Connection established 0xa4329740, tid 24110
[ 11-27 16:20:44.005 24092:24110 W/ ]
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
11-27 16:20:44.011 24092-24110/com.Frenchie.SurfaceView I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
11-27 16:20:44.011 24092-24110/com.Frenchie.SurfaceView I/OpenGLRenderer: Initialized EGL, version 1.4
11-27 16:20:44.011 24092-24110/com.Frenchie.SurfaceView D/OpenGLRenderer: Swap behavior 1
11-27 16:20:44.013 24092-24110/com.Frenchie.SurfaceView D/EGL_emulation: eglCreateContext: 0xa43328a0: maj 2 min 0 rcv 2
11-27 16:20:44.018 24092-24110/com.Frenchie.SurfaceView D/EGL_emulation: eglMakeCurrent: 0xa43328a0: ver 2 0 (tinfo 0xaeb325d0)
11-27 16:20:44.104 24092-24110/com.Frenchie.SurfaceView D/EGL_emulation: eglMakeCurrent: 0xa43328a0: ver 2 0 (tinfo 0xaeb325d0)
11-27 16:20:45.783 24092-24092/com.Frenchie.SurfaceView V/StudioProfiler: StudioProfilers agent attached.
11-27 16:20:45.828 24092-24158/com.Frenchie.SurfaceView V/StudioProfiler: Acquiring Application for Events
11-27 16:20:45.849 24092-24092/com.Frenchie.SurfaceView V/StudioProfiler: Transformed class: java/net/URL
11-27 16:20:45.851 24092-24092/com.Frenchie.SurfaceView W/zygote: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
11-27 16:20:46.312 24092-24092/com.Frenchie.SurfaceView V/StudioProfiler: Memory control stream started.
11-27 16:20:46.826 24092-24167/com.Frenchie.SurfaceView V/StudioProfiler: Live memory tracking disabled.
11-27 16:20:46.828 24092-24167/com.Frenchie.SurfaceView V/StudioProfiler: Live memory tracking enabled.
11-27 16:20:46.828 24092-24167/com.Frenchie.SurfaceView V/StudioProfiler: JNIEnv not attached
11-27 16:20:47.012 24092-24167/com.Frenchie.SurfaceView V/StudioProfiler: Loaded classes: 5094
11-27 16:20:47.416 24092-24167/com.Frenchie.SurfaceView V/StudioProfiler: Tracking initialization took: 588509880ns
あなたはどんなより多くの情報が必要な場合は私に知らせすることを躊躇しないでください。
例外が表示された場合は、logcatログを確認してそこに追加してください。 –
私はLogcat – Frenchie
からの出力はありませんが、持っている必要があります。 logcat watcherが添付されたエミュレータでアプリケーションを実行するか、[こちら](https://stackoverflow.com/questions/3359692/how-to-redirect-my-log-output-from-logcat-to-the-sd-実際のデバイスからログを抽出する方法については、カードオンアンドロイドデバイス)を参照してください。 –