버튼이 포함 된 격자 레이아웃을 만들려고하지만, 기본적으로이 버튼 사이에 공백이 있으므로 필요하지 않습니다. .xml 파일은 다음과 같습니다격자 레이아웃의 버튼 사이의 안드로이드 여백
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<HorizontalScrollView android:id="@+id/HorizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
</GridLayout>
</HorizontalScrollView>
</ScrollView>
내가 버튼을 생성하고 그리드 레이아웃에 추가하는 코드 : 여기
for (int rowCounter = 0; rowCounter < DIMENSION; rowCounter++)
for (int columnCounter = 0; columnCounter < DIMENSION; columnCounter++) {
Button b = new Button(this);
b.setText(" ");
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
params.setMargins(0, 0, 0, 0);
b.setLayoutParams(params);
gridLayout.addView(b);
}
은 어떻게 보이는지의 이미지 :
image http://i40.tinypic.com/zn1lwo.png
사용 hierarchyviewer 당신에게 선생님 감사합니다 – pskink