I required runtime dimensions of Relative/Linear Layout.
activity_home.xml:
we may not get correct height and wight of a view or layout as soon the activity is just created since the layout is not inflated completly
so
1.either you can let a runnable method triggered after some secs which in turn call a function that gets the width and height properties.
2.we can use view tree obsever
l = (RelativeLayout)findviewbyid(R.id.rl_cards_details_card_area);
ViewTreeObserver observer = l.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// TODO Auto-generated method stub
ActivityClassName.this.getProperties();
l.getViewTreeObserver().removeGlobalOnLayoutListener(
this);
}
});
void getProperties() {
int a= l.getHeight();
int b = l.getWidth();
Toast.makeText(getActivity,""+a+" "+b,1000).show();
}