I am developing an android app with a layout that includes buttons arranged around a circular element. As the corners of said element would overlap with other buttons, the recommended layout types (LinearLayout etc.) are not a viable option.
However, I want to do this right and not use the deprecated AbsoluteLayout. So far, though, I see no alternatives. Are there?
Relative layouts would probably work depending on how you want to place your buttons.
It allows you to place the buttons to the left/right of each other or above/under, so placing them around a circular element should be possible.
Here's the link to the android documentation for relative layouts.
Related
I want to make a similar layout in Android with two additional button in bottom right and left corner. I'm new to android development GUI. Is grid layout the best option to achieve this or I should use any other layout.
I would not suggest using GridLayout. If you can, try to use Constraints layout, if that is not an option, use combination of RelativeLayout and LinearLayout where needed.
There is no 100% correct answer, try multiple ways and you will find one that suits you the best.
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'm building an android project and I'm using eclipse.
I just can't figure out how to disable the annoying auto alignment.
I just want to place buttons wherever I want to drop them on the GUI interface but it just keeps
to align them one to another. I've tried to delete those alignment lines in the xml code
but it still brings them back as I move the buttons on the GUI interface.
Is there an way to disable that function?
Thank you,
Alex
Is there an way to disable that function?
Not in a way that you will find satisfactory, I suspect.
You have not really explained what the "alignment lines" are, so we are forced to guess. My guess is that the "alignment lines" are because you are working with a RelativeLayout container. Quoting the JavaDocs for RelativeLayout, RelativeLayout is:
A Layout where the positions of the children can be described in relation to each other or to the parent.
And, quoting the guide for RelativeLayout:
RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left of center).
Hence, the "alignment lines" are there, and are replaced by the GUI builder, because they are the point behind using a RelativeLayout container.
Of course, you are welcome to change the container that you are working with to something else.
However, in general, Android does not really support very well your stated objective ("I just want to place buttons wherever I want to drop them on the GUI interface"). Just as you don't do that in Web development, you don't do that in Android development, and for much the same reason: you need to take different sizes into account (browser window size for Web, screen size for Android). RelativeLayout, LinearLayout, TableLayout, and GridLayout are all designed to have you specify widgets plus rules for positioning and sizing, so that you can design a UI that will accommodate the difference between a 3" and a 4.5" screen, for example. This is akin to using HTML tags and CSS rules to define content and its positioning in a Web page. Eclipse's drag-and-drop GUI builder for Android can assist in your definitions of these rules, as you are perhaps seeing with your "alignment lines" for RelativeLayout.
I think I may be able to help. If you set your layout to Relative Layout you can drag and drop any of the views wherever on the eclipse GUI.
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.
we are confused with designing interface file for android,we have made user interface with Absolute layout and used "dip" instead of "px" (for different screen size issue) ,but it looks like,Absolute layout has been depreciated,and developer.android, recommends not to use Absolute layout
So other option we have is to use
1.Linear layout
2.Frame layout
3.Table Layout
But we are unable to bring Combination of above layouts so,that we can make button/widgets to proper position we need
How do we make widgets to desired position of screen with above said layouts and making them compatible with different screen sizes we have in android devices
would like to get a generic answer about same,
Tools used are: DrawDroid
The best layout to use if you were considering an AbsoluteLayout is a RelativeLayout.
Check out the Android Common Layout Objects page and its explanation of how to use a RelativeLayout.
Without more information on what you are trying to do, expanding this answer anymore is useless.