How to show multiple TextView 'inline' layout in Android? - android

For e.g. I want to show tags to some article (just like we have tags attached with each question on StackOverflow), I would like to show them like this:
Where the tags can be of variable length and they should span across multiple lines if they can't fit in the given width. I tried out LinearLayout and RelativeLayout but they don't seem to be able handle such 'auto' arrangement scenario. What layout or methodology should I use to achieve this effect?

This requirement is known as FlowLayout and I found couple of solutions as open source libraries to achieve this effect:
ApmeM/android-flowlayout
blazsolar/FlowLayout

Related

xml box layout or other suggestions

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.

Section Header using Android XML?

enter code hereLooking through the Android UI guidelines I came across this section / example:
In the example above, there are a few headers called 'SECTION' with a horizontal line underneath them.
Im still getting grips with the appropriate way to replicate this -
Is there something specific like a Header XML element to use that will automatically style the font and horizontal line? Or is something like this generally more primitive, i.e. A TextView with a 1 pixel horizontal image (ImageView?) underneath it?
Possible duplicate question of this one: Android 4.0 Sub-Title (section) Label Styling
In short: try adding attribute style="?android:attr/listSeparatorTextViewStyle" to the TextView element, which you wish to make look like that, in the XML layout file.

iOS: How to achieve relative layout

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.

How do I create a panel of buttons with a simple divider line, or no dividers, in Android?

This seems like a really basic task, but after a lot of searching and research, still haven't found a clear answer. I found GridView, but not sure this is how you're supposed to do it.
I've found several apps that have UI elements similar to what I need, for example the top buttons of the android market.
That can easily be accomplished with a horizontal LinearLayout that contains a set of Buttons or ImageButtons. The rest is just styling.
See Hello Linear Layout to get started.

How to create "floating TextViews" in Android?

I'm programmatically putting various TextViews into a LinearLayout with a horizontal orientation.
After 2h of research I couldn't find out how to tell Android not to squeeze all the TextViews in one line but instead to "float" non-fitting TextViews into the next line.
I know there isn't something like actual "lines" in a LinearLayout, but how can I tell the TextViews to actually behave like floating DIVs from the HTML world?
Thanks alot!
Use RelativeLayout. In addition to allowing to you to set up Views relative to each other, it can also align them relative the parent.
Specifically, look at RelativeLayout.LayoutParams, with which you can do something similar to float with alignParentRight/alignParentLeft and so on.
It sounds like you're looking for something like a FlowLayout in Java? I found an answer in this question that looks immensely helpful for what you're trying to do.

Categories

Resources