android 随笔之 GridLayout

mGridLayout = (GridLayout) findViewById(R.id.gridLayout);
columnCount = mGridLayout.getColumnCount();
screenWidth = this.getWindowManager().getDefaultDisplay().getWidth();//获取手机屏幕宽度
Log.e(TAG, "column:" + columnCount + "; screenwidth:" + screenWidth);
for (int i = 0; i < mGridLayout.getChildCount(); i++) {
Button button = (Button) mGridLayout.getChildAt(i);
button.setWidth(screenWidth / columnCount);
}

 

posted @ 2019-05-18 21:20  a5365958  阅读(196)  评论(0编辑  收藏  举报