0
버튼을 10x10 보드로 만들지 만, 프로그램을 실행할 때마다 더 이상 볼 수 없을 때까지 버튼이 아래쪽으로 확장되어 있습니다. 여기에 내 코드입니다 :TableLayout 문제
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.game);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(32, 32);
final TableLayout container = (TableLayout) findViewById(R.id.tableLayout5);
Button btn[][] = new Button[10][10];
for(int i = 0; i<10; i++){
for(int j = 0; j<10; j++){
btn [i][j] = new Button(this);
container.addView(btn[i][j],i,lp);
}
}
}
내 XML 코드
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout5">
<Button
android:id="@+id/newgamebutton"
android:layout_width="225dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/newgame" />
<TableLayout
android:id="@+id/tableLayout5"
android:layout_width="fill_parent"
android:layout_height="400dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/newgamebutton"
android:orientation="vertical" >
</TableLayout>
</RelativeLayout>
나는 버튼이 하단에있는 모든 방법을 확장하는 이유를 궁금해하고있는 뭔가가 있다면, 나도 몰라 사라지는거야 내 레이아웃 높이로할지 어떨지. 나는 10x10 보드처럼 보이게하려고합니다.
시도는 왜 안 그리드를 사용하십시오있는 ScrollView – Raghunandan
내부 TableLayout을 넣어? – Giant