Skip to content

Instantly share code, notes, and snippets.

@martincox
Created March 4, 2016 23:26
Show Gist options
  • Save martincox/98b20680f7ac120ff420 to your computer and use it in GitHub Desktop.
Save martincox/98b20680f7ac120ff420 to your computer and use it in GitHub Desktop.
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.GridLayout;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridLayout gridLayout = (GridLayout) findViewById(R.id.grid_layout);
View tileA = getLayoutInflater().inflate(R.layout.tile, null);
View tileB = getLayoutInflater().inflate(R.layout.tile, null);
GridLayout.LayoutParams first = new GridLayout.LayoutParams(
GridLayout.spec(0, 1),
GridLayout.spec(0, 1, 100.0f));
gridLayout.addView(tileA, first);
GridLayout.LayoutParams second = new GridLayout.LayoutParams(
GridLayout.spec(0, 1),
GridLayout.spec(1, 4, 100.0f));
gridLayout.addView(tileB, second);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment