|Related to : What's the difference between android:height and android:layout_height?|
|Android xml layout file , see actual height for a layout in android xml layout designer|
If you want to add views programatically, you can get the width by
inner.getWidht(). If you want to add views in the xml, you have to add
linear layouts to inner, and you can add view to these relative
layouts by setting their weight.
|Android layout Height and width|
Your question largely depends on whether you are in portrait or
If you are trying to make a layout width to match the height in
portrait, then your layout will be going off screen, which does not
seem possible in xml. And vice-versa, matching the height to the width
in landscape would make the layout go offscreen as well.
If you are trying to make a square layout the same dimension as
|Android layout auto height|
try to give width to the textview
|Android set layout to take the rest of height|
If all three layouts at the same level then you can do following.
HorizontalScrollView = > set height 150dp
RelativeLayout => set height 50 dp
|Two ways of specifying the height of an android Layout?|
If size is determined dynamically, you may need to use
ViewTreeObserver to get the size seen on the screen.
Set your width and height in defining your params. If you want the
width to be match_parent, change your code like below and it is going
to work (if you don't want match_parent, just set the width that you
desire in the code below):
RelativeLayout.LayoutParams params = new RelativeLayout