嗨,我有一个具有布局的活动类,布局本身有一个自定义视图,这是活动类:
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。