Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layout aligning problem

 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have problem with layout which i cannot align elements where i really want to.

There is a small picture of layout design which i want to create but i came up with mess.
So, what i want is force listview use only blank area (shown as white) and OK/Cancel buttons are (ALWAYS) keep bottom.

I fixed this issue by hard coding about height and as you may guess my layout mess up with different size of Screen resolution.
My current layout is :

LinearLayout (Vertical)
|_ FrameLayout (Holds App title)
|_ LinearLayout (Horizontal)
|_ ListView
|_ FrameLayout (Holds buttons)

When user type something into textbox and hit OK button i want to show it in Listview and if there are too many items in it
then start scroll but ONLY listview.

App Title, Textbox and Buttons MUST stay same position.

I really appreciate for any help/idea.

Regards
Untitled.jpg
[Thumbnail for Untitled.jpg]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will give you the same advice I gave you last time you asked this question: use a relative layout:
RelativeLayout
|-- App Title (aligned to parent top, aligned to parent left, aligned to parent right)
|-- Text Box (below Title, aligned parent left, aligned parent right)
|-- OK buttun (aligned to parent bottom, aligned to parent start)
|-- Cancel button (aligned to parent bottom, aligned to parent end)
|-- ListView (below TextBox, above OK button, aligned parent left, aligned parent right

The app title is forced to the top of the screen. The Text box is forced underneath it. The buttons are placed at the bottom of the screen, and the list fills the space in between.

You might want to reverse the OK and Cancel buttons - put the OK on the right / end and the Cancel on the left / start. This is an Android OS convention that makes your app fit better with user expectations.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below are screenshots of a layout as described above.
Big Layout.png
[Thumbnail for Big Layout.png]
Layout using RelativeLayout on a 4.5 in display
Small Layout.png
[Thumbnail for Small Layout.png]
Layout using RelativeLayout on a 3.2 in display
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Steve

I don't know who you are. I will look for you. I will find you and I will buy a beer for you.

I tried relative layout couple of times before but i didn't know Start and Stop points of elements.
So, i have assigned unique ID each layout and now it works like charm.

Thanks for your help.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic