I am starting to delve into Android Development and there is a lot of material online. The question is... What are the pro's and con's against the drag and drop XML design method vs coding the view manually? The only reason I ask on here is because online the views are mixed and they don't really back up what they're defending.
If I use the drag and drop method will I have issues further onto my development adventures? That is the thing that worries me the most... I don't want to learn the drag and drop method and then editting the XML to cater for my needs and then be handicapped by it.
For the beginner(s), I highly recommend not to use Drag and drop. We need to understand XML, to be comfortable with android widget. Understanding XML will come handy in future when creating custom styles and themes.
Here are few pointers before you dive in android XML layout
Try sticking with match_parent and wrap_content while defining android:layout_height or android:layout_width if possible
Make sure you have good understanding of RelativeLayout, LinearLayout and FrameLayout and how its child views are arranged.
Forget about ConstraintLayout, AppbarLayout and similar advance layout at current.
Try exploring TextView, EditText, Button, ImageView and ProressBar as far as possible.(This are most common widgets/views)
Try avoiding any tutorial related to ListView, its deprecated. Try using RecyclerView instead, it is one of the important widget that would be used in regular basis.
Related
I am developing an android app and I am used to relative/linear layout but now I decided to use ConstraintLayout. I am a novice in ConstraintLayout. I was reading some documents online and I have also read an official android document on ConstraintLayout.
ConstraintLayout give us a linear and flat view for our layout.
I have few doubts/questions in mind which I didn't found in the official document:
Can we use RelativeLayout or LinearLayout inside ConstraintLayout? Is it standard practice or not?
If yes, then does it create a multi-layer inside ConstraintLayout?
If no, then how should we manage some small UI components in ConstraintLayout? because I have one design which requires to combine two/three view and need some separate background. we can achieve easily this with RelativeLayout or LinearLayout?
Could anyone please help me to understand ConstraintLayout.
Can we use RelativeLayout or LinearLayout inside ConstraintLayout? Is
it standard practice or not?
No. You should not. You should read Optimizing Layout Hierarchies and Performance and view hierarchies
If yes, then does it create a multi-layer inside ConstraintLayout?
Same as above. [yes it creates multi layer]
If no, then how should we manage some small UI components in
ConstraintLayout? because I have one design which requires to combine
two/three view and need some separate background. we can achieve
easily this with RelativeLayout or LinearLayout?
There are ways to do almost everything using ConstraintLayout. As being a novice of this Layout, you may be frustrated when you face difficulty to create a few complex designs. But after some time you will forget to use even RelativeLayout :). Read the link provide by Rajnish in the comment and ConstraintLayout. There are several videos you may find to learn.
It is not considered best-practice to use RelativeLayout/LinearLayout inside ConstraintLayout but ConstraintLayout has many "Widgets" to help you design your screens
This is a great source to understand the different "Widgets"
I was curious about knowing that why this happens in android studio when I'm trying to graphically edit layouts. Every views and attributes are reorganised. is there any rendering benefits or any benefits at all?
Because its not a drag and drop editor. Not really. You're putting children into a parent layout, which works on certain rules. When you drag children around, you change the rules but you're never putting it in a particular place.
I really, really, really suggest you don't use the graphical layout editor. Its confusing, not very accurate (especially if using custom views) and inefficient. Learn how to write layout xml, you'll be much faster and write easier to maintain layouts. Most pro devs don't use it at all.
I am creating an Android app in Eclipse, but when I drag around a TextView, everything below it moves around as well.
This is when I haven't dragged anything.
http://i.stack.imgur.com/Twp4L.png
This is when I drag the TextView just a bit.
http://i.stack.imgur.com/oJ75k.png
The layout designer doesn't work very well in Eclipse. You could try Android Studio's layout designer (the new early access preview), that one is a bit better, but not by much.
The most common practice is to use the layout designer to only get started with and perhaps to use the Outline view panel to tweak some of the nesting of the layouts/views by dragging some of the nodes inside it, but then it's to dive directly into the xml code yourself. There is really no other substitute for doing that. The tool just isn't very good yet.
This is called a Relative Layout. In this case, the components are placed relative to the TextView, which is not so unexpected. It depends how you set relations in the layout XML. What layout you want to achieve?
You can either set that all the components are placed relative to the whole view, or use some specialized layout types like LinearLayout. It all depends on the effect you want to achieve.
I am very new to Android development and am having some trouble. I am creating an XML file using Eclipse, both the Graphical Layout feature is what I'm having trouble with.
Also, I am working in Android 2.3 for compatibility reasons.
I am wondering if there is a layout which enables me to place buttons or text fields or any attribute where I want to put them. This may sound stupid, but it seems that every layout has some sort of order in which it lets you add attributes, and whenever I try to drag them elsewhere on the layout things just get very very messy.
If what you want is an AbsoluteLayout, this has been deprecated since Android 2 (IIRC). You can try using the RelativeLayout, which let you position freely your widgets. Else, if you only use LinearLayout, then yes the widget will be positioned in a strict way.
use Relative Layout. I recommend that you read up on Android layouts so you understand why, what and hows of Android way. There are some good tutorials that I found helpful. TutsPlus: Android Layouts
There is also a very good video from Marakana.
Marakana: Android Bootcamp
If you are just starting out with Android check other tutorials/videos on Marakana. They are a very good resource for beginners.
Here is a video of my app:
It's currently using absoluteLayout, and since absoluteLayout is deprecated i decided to change my layout.
So what Layout do u suggest using for this app?
Please see the part of the video, that the game has started, that's the only part with absolutelayout.
Thanks
It really depends if you want your UI to flow in a linear fashion or not. The majority of the time I use RelativeLayout with some instances of LinearLayout here and there. Relative seems to me the most flexible for me.
"You can achieve much the same layout by using a FrameLayout instead, and setting layout_margin attributes of the children. This approach is more flexible and will yield better results on different screens."