在onCreate方法(Android )中,获取视图的高度(范例)

・1 分钟阅读

 

final LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
final ViewTreeObserver observer= layout.getViewTreeObserver();
observer.addOnGlobalLayoutListener(
 new ViewTreeObserver.OnGlobalLayoutListener() {
 @Override
 public void onGlobalLayout() {
 Log.d(" Log" ," Height:"   layout.getHeight());
 }
 });
Zas12357386 profile image