Suitable layout for grid of buttons in android - android

I am confused with the appropriate layout design to be used for grid of buttons. I want to display a "textview and EditText" at the top. Below that there should be a 3*4 grid/matrix of 12 buttons(like cell phone keys), following another three linear buttons at the bottom of the root layout. (upper layout should not overlap the bottom buttons).
It would be of great help if anybody guide me in this regard.

UI layouts are done using xml files. Read about it before you start
While this is not exactly what you want here is a something to get you going.

Related

Android image button format

I am making an Android app and have created some imagebuttons for navigation. However, when I assign images to the buttons, the height of the button is never fully filled by the images as can be seen here (the underlying button sticking out has been circled - more obvious in the large bottom button)
For my layout Ive used a Relative layout for the main view and a Linear layout (Vertical) to stack the buttons.
Apart from creating the buttons in xml and adding images to them, I have done no other coding on the buttons yet.
Been trying to figure out all the drawables first but its as confusing as a bag of cats.
Can anyone tell me why this is and how I can possibly fix it?
To me it just looks like you used
android:src="#drawable/image"
instead of
android:background="#drawable/image"
(That is assuming you are doing this through XML)

Grid or relative layout

I want to have a page in an app have multiple buttons (in grid fashion) I was wondering if it would be better to populate a grid layout with buttons or manually add buttons to a relative layout, or if it even matters. I want each button to do something different so if using a grid layout is better how would I do this. I know you need to have gridview.setOnItemClickListener but that would make each button do the same thing (I think). Any suggestions would be appreciated!
If you have a fixed number of buttons, use a RelayiveLayout or TableLayout. If you have an unknown number of buttons and want to be able to scroll through them, that's the time to use a GridView.

How to arrange overlapping buttons in Android xml layout?

In my layout there are three buttons and want to set PNG images for the buttons background but, the buttons overlap a little bit on one another. I want to how arrange the button in my layout. Which layout would be better for me in this context. You can see image of the layout below, that I want to develop. Please help me in this respect; your help would be cordially appreciated.
You could put all 3 buttons in a container, for example a RelativeLayout.
The center button (big one) would be aligned as "centerHorizontal=true". The left and right buttons would be aligned as "alignParentLeft=true", and respectively "alignParentRight=true". Plus, both buttons to have some margins on top.
I believe you can achieve the desired effect.
At least you can use AbstractLayout,although it is deprecated.

Android - Overlapping Adjacent LinearLayouts, Overlaying LinearLayouts

I am porting an iOS application so the design is pretty much out of my hand. What I have is two LinearLayouts, one with what is basically a bump (shown in pictures) that I want to overlap the second LinearLayout.
I get aesthetically what I want desire I use FrameLayout to contain the two layouts. However, here I run into two functional problems. The first, I need to be able to allow the bottom, overlapping LinearLayout which is composed of five adjacent image buttons to change size (preferably, using layout_weight). The second is anything that is in the bottom of the top LinearLayout it is hidden by the bottom LinearLayout.
When I switch to using LinearLayout, from FrameLayout to contain the two I get functionally what I want, however, aesthetically it smashes the button to fit.
Both cases are pictured. All feedback is appreciated. I am hoping to find a solution to this without designing a custom widget.
Thanks.

Aligning components at desired positions

Seeking help to design a layout as shown here:
http://docs.google.com/Doc?docid=0AQhgDtGvE2HgZGZ6cmtua185MTd0eGdyZmc&hl=en
The major challenge I face is aligning the components at desired positions. Please refer the three buttons(icons) and the way they are positioned.
Literally, going nuts, thinking how to position those exactly at the desired places.
Any help is much appreciated.
Regards,
Rony
Since you used the Android category, I'm assuming that you're trying to recreate this iPhone layout in Android.
The three buttons would probably be best laid as follows.
Your main layout container would probably be a RelativeLayout, so you can dock things to the top and bottom and lay everything else out in relation to one of its sibling elements. The three button icons (and I'm assuming you're referring to the circular buttons and not the tab bar buttons at the very bottom) would be in a LinearLayout centered within its parent (probably want to use gravity=center_horizontal on the main outer layout) and the individual items would have an equal left and right margin parameters to get the desired spacing (layout_marginLeft, layout_marginRight). You could also make the LinearLayout container of the buttons flush (layout_width=fill_parent) and using android:weight attribute on the outer buttons laying them out towards the center and using a lower weight on the center item. I'd favor the first option, personally.
If you're trying to create relatively complex layouts and any of the above doesn't make sense, go back and read the docs. Layout in Android is very powerful, but you really have to understand the available tools to take advantage of it.

Categories

Resources