1
ボタン、テキストなどをキャンバスの上に重ねるにはどうすればよいですか?次activity_game XMLとキャンバスの上にオーバーレイする方法(Android)
public class GameActivity extends AppCompatActivity {
private GameView gameView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameView = new GameView(this, scrWidth, scrHeight);
setContentView(gameView);
}
}
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.exampl.proj.GameActivity">
</RelativeLayout>
すべての描画がGameViewクラスで行わ
は私が活性を有しています。
public class GameView extends SurfaceView implements Runnable {
私はXMLでのImageButtonに入れてみましたが、私がsetContentViewがgameViewクラスに焦点を当ててからだと推測見えるwouldntは。
ContentViewをactivity_game XMLレイアウトに設定し、コンストラクタにパラメータを渡すことができるようにGameViewを実行し続けることはできますか?