Android: Scale number of columns in game grid according to screen width.

This commit is contained in:
Eder Bastos 2015-05-11 17:06:54 -04:00
parent 3bea58e4f8
commit 06b7b20e5f
5 changed files with 18 additions and 1 deletions

View File

@ -54,7 +54,8 @@ public final class GameGridActivity extends Activity
//mRecyclerView.setHasFixedSize(true);
// Specifying the LayoutManager determines how the RecyclerView arranges views.
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this, 4);
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this,
getResources().getInteger(R.integer.game_grid_columns));
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="game_grid_columns">4</integer>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="game_grid_columns">2</integer>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="game_grid_columns">3</integer>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="game_grid_columns">1</integer>
</resources>