I required runtime dimensions of Relative/Linear Layout.
activity_home.xml:
<RelativeLayout
android:id="@+id/rlParent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
HomeActivity.java:
private int width, height;
RelativeLayout rlParent = (RelativeLayout) findViewById(R.id.rlParent);
w = rlParent.getWidth();
h = rlParent.getHeight();
Log.i("Width-Height", width+"-"+height);
Please share your thoughts.
Try this
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
updateSizeInfo();
}
private void updateSizeInfo() {
RelativeLayout rlayout = (RelativeLayout) findViewById(R.id.rlayout);
w = rlayout.getWidth();
h = rlayout.getHeight();
Log.v("W-H", w+"-"+h);
}