I wanted to implement a chessboard with gridlayout & framelayout. When I hardcoded the xml everything works fine. But when I tried to implement it programmatically all things fall apart. In xml I added
android:background="@color:blue"
to framelayout and it made a blue square but when I do this dynamically like
framelayout.addBackground(drawable)
no square shows up unless it has a child in it Broken chessboard
Also how to change the size of the chessboard square dynamically? It seems like gridlayout's grids don't get size from its parent rather from its child. Any help is much appreciated. Take love.
I forgot to set height, width to the framelayout. That's why it was not showing anything. The potential solution is:
framelayout.setMinimumHeight(height);
framelayout.setMinimumWidth(width);