嗨,我有一個具有佈局的活動類,佈局本身有一個自定義視圖,這是活動類:佈局與自定義視圖
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格,所以我的問題是如何把它移到我自定義的veiw下面? 我已經嘗試改變自定義視圖的layout_width和layout_height了。
當只有一個辦法你想改變按鈕的位置,爲什麼你要改變你的佈局寬度? –
嗨感謝您的回答,因爲自定義視圖已經佔用了屏幕上的所有空間。 – rGhazaliii