android - How to superimpose a GridLayout on a ImageView? -


i'm making tic tac toe on android fun, , don't know how design it. in fact, made grid layout have 9 interactiv squares don't know how put grid's picture under it.

first put grid on background attribute:

<gridlayout     android:id="@+id/game"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:layout_centerhorizontal="true"     android:columncount="3"     android:rowcount="3"     android:numcolumns="3"      android:background="@drawable/grid"     > 

but didn't work :

then tried put imageview parent of gridlayout it's impossible. there other way ?

the concept of gridlayout or table layout setup grid you've done , add child components each grid element. in case of tictactoe board, i'd suggest added 9 imagebuttons, 1 each box. when user clicks on button, can change image blank either x or o.

this example pulled dialed, has similar grid/table concept.

       <imagebutton             android:id="@+id/imagebutton_dtmf_1"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:background="@drawable/btn_dial_1"             android:contentdescription="@string/dialer_button_1" /> 

in java code, you'll identify each of 9 imagebuttons , set click listener each of them.

here basics of gridlayout: http://www.techotopia.com/index.php/working_with_the_android_gridlayout_in_xml_layout_resources


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -