在Android中,可以使用以下方法来获取控件的宽高:
View view = findViewById(R.id.your_view_id); int width = view.getWidth(); int height = view.getHeight(); View view = findViewById(R.id.your_view_id); ViewTreeObserver vto = view.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int width = view.getWidth(); int height = view.getHeight(); // do something with width and height } }); 通过以上两种方法,就可以在Android中获取到控件的宽高值。