Android: Scale number of columns in game grid according to screen width.
This commit is contained in:
parent
3bea58e4f8
commit
06b7b20e5f
|
@ -54,7 +54,8 @@ public final class GameGridActivity extends Activity
|
||||||
//mRecyclerView.setHasFixedSize(true);
|
//mRecyclerView.setHasFixedSize(true);
|
||||||
|
|
||||||
// Specifying the LayoutManager determines how the RecyclerView arranges views.
|
// 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.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
|
recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="game_grid_columns">4</integer>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="game_grid_columns">2</integer>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="game_grid_columns">3</integer>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<integer name="game_grid_columns">1</integer>
|
||||||
|
</resources>
|
Loading…
Reference in New Issue