-1

Relative Layout has been in a pain in the butt for me and every time I move one thing at least a few others will follow. I'm looking for a way to disable relative layout or use a layout that allows me to move anything anywhere I want it. From what I saw grid layout, linear layout, and frame layout didn't allow that. Could anyone throw me some suggestions or it could be possible I jsut have no idea how to use these layouts lol.

bobshishka
  • 53
  • 1
  • 7
  • FrameLayout and its LayoutParams can do that – pskink Sep 20 '14 at 06:24
  • Supporting multiple screen sizes requires some thought how your elements' positions relate to each other. RelativeLayout is not a bad choice for that. – Henry Sep 20 '14 at 06:25
  • 1
    so basically you just want to use drag and drop without doing any xml coding... good luck to you `:P` trust me try to learn how to use xml for views and you can achieve almost anything you wish. – SMR Sep 20 '14 at 06:36
  • 1
    I just don't want everything to move whenever I move 1 thing. I heard something about containers. can anyone elaborate on that or find a good tutorial on how to use them? – bobshishka Sep 20 '14 at 06:37

2 Answers2

3

You should always must know when to use which layouts ?


Your choice depends on the requirements you have

Have a look at this answer i posted on a similar question

Definitions:

enter image description here


More Information:

FrameLayout:: enter image description here RelativeLayout:: enter image description here TableLayout:: enter image description here


Note:- Absolute Layout is depricated

Source: Android Developers


Note that Relative Layout reduces your view hierarchy to maximum extent

Optimization::Have a look at Optimizing Layout Hierarchies

The Fewer Views, the Better::

  1. The number one goal for your layouts should be using the fewest number of Views possible. The fewer Views you have to work with, the faster your application will run. Excessive nesting of Views further slows down your application.

  2. A RelativeLayout hierarchy will typically use fewer Views and have a flatter tree than a LinearLayout hierarchy. With LinearLayout, you must create a new LinearLayout every time you want to change the orientation of your views – creating additional Views and a more nested hierarchy. As a result, it is recommended that you first use RelativeLayout for any layout that has any complexity. There is a high probability you will reduce the number of Views – and the depth of your View tree – by doing so.


Community
  • 1
  • 1
Devrath
  • 42,072
  • 54
  • 195
  • 297
0

The ViewGroup Docs will help you set some of your definitions straight for starters.

You can't exactly get rid of RelativeLayout per se, you will always need to organize your Views into some ViewGroup/Layout (these two words are interchangeable). I've found for basic stuff you can almost always get RelativeView, LinearView (or most importantly a combination of the two) to provide the behavior you need.

RelativeLayout when have to specify things with realation to each other,

LinearLayout orientation:vertical when you need stuff displayed on top of eachother, and

LinearLayout oreintation:horzontal when you need stuff displayed side by side.

Nesting these three types of groups inside of each other takes a while to get the hang of, but is pretty powerfull.

this link always helps me too... hope this helps

Community
  • 1
  • 1
Will Thomson
  • 875
  • 6
  • 19