본문 바로가기

Programming/Android

[Android] Fragment Width(넓이)

mRootLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
	@Override
	public void onGlobalLayout() {
		mFragmentWidth = getView().getWidth();
		mFragmentHeight = getView().getHeight();
		if (mFragmentWidth > 0) {
			ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mFragmentWidth);
			mMapView.setLayoutParams(params);
		}
	}
});