当然,我知道它会返回 0 个度量,直到它被绘制到窗口。但是我需要获取布局的高度,因此应该调整子视图。下面是我的代码片段。在这个类中,我使用适配器类生成 36 个编辑文本。所以我需要根据屏幕获取布局的高度来调整edittexts。屏幕高度对我的应用没有帮助。任何代码片段将不胜感激。提前致谢。
public class GameView extends Activity implements OnClickListener {
FrameLayout frameLayout1;
GridView gridView;
EditText et[][]=new EditText[6][6];
TextAdapter textadapter;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gamedisplay);
frameLayout1=(FrameLayout)findViewById(R.id.fLayout1);
int layoutHeight = frameLayout1.getMeasuredHeight();//this is I need. So according to this I make adustments to edittexts.
Log.d("tag"," height :: " + layoutHeight);
System.out.println("In gameview >>>>>>>>>>>>>>>>>>>>> "+layoutHeight);
gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new TextAdapter(this));
//gridView.setVerticalScrollBarEnabled(true);
WindowManager wm=getWindowManager();
Display display=wm.getDefaultDisplay();
int gridSize = display.getWidth();
int colWidth = (gridSize / 6);
gridView.setColumnWidth(colWidth);
// getEditTexts();
// putValues();
}