こんにちは、レイアウトを持つアクティビティ クラスがあります。レイアウト自体にはカスタム ビューがあります。これがアクティビティ クラスです。
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class Minesweeper extends Activity {
public static final String KEY_DIFFICULTY = "minesweeper.difficulty";
public static final int DIFFICULTY_EASY = 1;
public static final double DIFFICULTY_MEDIUM = 1.5;
public static final int DIFFICULTY_HARD = 2;
private int diff;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff = getIntent().getIntExtra(KEY_DIFFICULTY, DIFFICULTY_EASY);
diff++;
Log.d("diff", String.valueOf(diff));
Mine.setlevel(diff);
setContentView(R.layout.minesweeper);
Mine.clearMines();
}
}
アクティビティのレイアウトは次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" >
<com.mine_sweeper.Table
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>`
レイアウト ファイルの Eclipse のグラフィカル ビューではすべてが適切ですが、レイアウト ファイルにボタンを追加しようとすると、カスタム ビューの左側にのみくっつきます 魔女は 9*9 グリッドなので、下に移動する方法が問題です私のカスタムビュー?カスタム ビューの layout_width と layout_height を既に変更しようとしました。