I am trying to get the dimensions of my RelativeLayout
.
I am told by many to use the following codes:
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.myRelativeLayout);
int layoutWidth = relativeLayout.getWidth();
int layoutHeight = relativeLayout.getHeight();
My problem is that all the ids I can find in my R.id
are all buttons, text views, and all that kind. There is nothing like layout id at all!
Then I try to write:
relativeLayout = (RelativeLayout) findViewById(R.layout.main_activity);
relativeLayout
is null when run. So it is also incorrect.
Do I need to add the layout id manually into R.id
? I don't think so.
But why there is no id for the layout in R.id
?