I am programming an android app for making work-fiches, main screen needs to show some summary of:working hours, parts used, remarks, ... , how can i design in xml these boxes the best way? I need a title, an summary content, clickable,...
The android design guidelines doesn't give me immediately a solution for it, also it is very difficult to find an example of it so i know which xml attributes to use, frame layout was helping me first but seems to give me some problems by now,
Thanks for your ideas in advance.
I suggest to go with Relative Layout, its the best layout present which requires a minimum no. of lines as compared to other layouts and align views with respect to each other. If you want views to be divided in proportion then it is recommended to use Linear Layout using weight concept.
Related
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.
I have a xml layout for displaying some results, depending on the result type I need to adjust this view changing 2 textViews and one ImageView, the rest of the layout keeps without changes.
The solution I think is the best is to change the text and the image inside my java code (programmatically).
A friend suggests that is better to make a copy of the entire layout and change this 2 text labels and the image.
IMHO that leads into duplicated code that is why I do not think this is the best option. What do you think is the best approach ? Do you think of a better one?
Thanks in advance.
You are in the right direction. Using 2 different layouts for different results will be absolutely redundant. You can set TextView values by :
textView.setText("Your Text")
and Image resource programatically by:
imageView.setImageResource(R.drawable.yourImage); according to your result.
I have been searching this on net and found various answers to this question.
I have been very confused to understand what is the best and standard way to create layouts in android.
Either,
Create a Parent Relative layout and put all items in the same
Layout.
Or
Create different relative or linear layout for each item, and a Parent layout that covers all the elements and child layouts.
Kindly guide me which one is the best and industry standard way.
Thanks
There isn't a standard way. All widgets are tools you can use for your convenience. However, be aware of performance when designing your layouts.
Maybe there is a golden rule:
The rule when constructing Android layouts is to make the layout shallow and wide rather than narrow and deep.
Please, read carefully this and this. Both tell us how to make fast Android layouts.
I'm trying to make an iOS version of my Android app. It contains text that looks like this:
There are three labels: title, author, and publication year. I need to display the full title, which may be several lines long. However long the title is, I want the author label to be directly below the title, and the pub. year directly below that.
In Android, I just used relative layouts to achieve this effect. How can I do this in iOS? Can Auto Layout do this for me somehow? If not, do you have any suggestions for effectively displaying this information in iOS? Preferably I'd like to achieve this using the storyboard.
In iOS you use InterfaceBuilder IB for layouts - it's drag and drop - not like Android layouts.
Search for IB tutorials - it is really straight forward and you see what you get:-)
I also searched quite some time a way to achieve android-like layouts in iOS (without the hassle of computing every positions for each subviews).
I eventually gave up and coded a fast equivalent of VerticalLayout and HorizontalLayout. Here's the repo (it's ARC compliant) :
https://github.com/kirualex/iOS-Layout-helper
It's sketchy but it does the work !
Put simply relative layout organises items on the screen relative to something else. Like linear layout, relative layout is commonly used by android developers. I myself do like this layout and have used in the development of my applications before. See
http://developer.android.com/reference/android/widget/RelativeLayout.html and http://developer.android.com/guide/topics/ui/layout/relative.html for more information on relative layouts.
Hi im just starting to make an app, and on eclipse i get 2 tabs. Graphical layout is one of them. I see a black cell phone screen and some buttons and text stuff to put on it. What is this for and how do i use it? Thank you
With the graphical layout you can just drag and drop items in, and the xml is the actual code. Adding things via the graphical layout will edit your code for you, and visa versa. Personally I prefer to just use the xml because the graphical layout can be a little difficult to get the results you want, and it's always useful to have a good understanding of the xml code and how it works.
Android uses XML layouts. They can be a real pain to edit. The graphical layout tab with the picture of the phone is supposed to make it a little easier.
Sometimes you still have to dip down into the XML to get things just right, but the graphical layout will at least give you a preview.
It's your Interface Builder.
It builds interfaces ;)