0
xml
에 정의 된대로 GridLayout
을 사용하여 15 (너비) x20 (높이) "그래프 - 용지"보기를 생성하려고합니다.GridLayout 동적으로 ImageView를 연결하십시오
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="15"
android:orientation="vertical"
android:rowCount="20"
android:layout_margin="2dp"
android:id="@+id/gridLayout_mazeLayout">
<View
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_row="0"
android:layout_column="0"
android:background="#51ffff"
android:layout_margin="1dp"/>
<View
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_row="0"
android:layout_column="1"
android:background="#51ffff"
android:layout_margin="1dp"/>
<View
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_row="0"
android:layout_column="2"
android:background="#51ffff"
android:layout_margin="1dp"/>
// rest of rows and cols not shown.
</GridLayout>
I는 3 × 3 셀
gridLayout_mazeLayout = (GridLayout) rootView.findViewById(R.id.gridLayout_mazeLayout);
ImageView imageView_robot = new ImageView(rootView.getContext());
imageView_robot.setBackgroundResource(R.mipmap.imageacross3x3);
GridLayout.Spec row = GridLayout.spec(0);
GridLayout.Spec col = GridLayout.spec(0);
GridLayout.LayoutParams gridLayoutParam = new GridLayout.LayoutParams(row, col);
gridLayout_mazeLayout.addView(imageView_robot,gridLayoutParam);
그러나 그렇게 걸쳐하는 ImageView
을 첨부하고 싶은는 ImagineView
을위한 새로운 공간을 소개하는 것 같다. 달성하고자하는 것은 GridLayout
에 추가하는 대신 ImagineView
을 셀의 맨 위에 첨부하는 것입니다.