Reputation: 408
Suggest me on this I have to use some header and body part in android screen design, Can i use plain Linear layout for screen design or can i use relative layout or else both layout combined together.For the header bar im using a gradient image and application runs both in vertical and horizontal orientation. As of now im using two main linear layouts for the first one im using a height of 40 dp and for the second i just used 0dip is this a correct way of approach or i have change anything.
Upvotes: 0
Views: 761
Reputation: 6925
Don't mix concept of RelativeLayout
and LinearLayout
. RelativeLayout
is preferred because it reduces extra lines as compared to LinearLayout
. In RelativeLayout
views are placed relative to each other i.e. left, right, top and bottom unlike LinearLayout
where you can't place view in respect of some other view. Both have its own advantages. As Weight concept is not supported by RelativeLayout
but LinearLayout
.
Depending on the complexity of layout both are chosen. One thing to avoid is un-necessary nesting of layouts which reduces performance. I would recommend read concepts of RelativeLayout
, LinearLayout
and weight first then you will be able to judge which layout to use on your own. Till then use RelativeLayout
as it requires minimum number of lines.
Upvotes: 2
Reputation: 1617
You can use Linear-Linear, Linear-Relative or Relative-Relative. Anything you want.
Your question is hard to understand. From what i get, i think your approach is fine. You should let the Screen design (second layout) use "match_parent". It will take up remaining part. For your header layout using "40dp" is fine. I made app with Header, and i used this approach.
If in Header, you are adding images as well as TextView, it is advisable to use RelativeLayout. In the rest part, use however you need it.
Upvotes: 0