Tuesday, 15 September 2015

Simple Android layout issue -


I want to do something very simple I want a layout that has a spinner at the top, then there is a list view, After that there is a linear layout below a lot that rolls up some buttons. I want to extend the list view to fill the space between the spinner and the button, no matter how big a window. I'm trying this with a linear layout wrapping all three elements and I say 300 dive to Layout_Height Wrap material and fill parent's each combination that I try but unless I can think of hard code list in layout Layout_Height The button is pushed, the screen is off I know that there should be an easy way to do this, but I'm at the end of my mind. Whatever I can think of, I have to try them all.

Here is the code that works with the link-coded height.

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" Android: Layout_width = "Fill_parent" Android: Layout_height = "Fill_parent" android: orientation = "vertical" & gt; & Lt; Spinner Android: id = "@ + id / fileType" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" /> & Lt; ListView Android: id = "@ + ID / Android: list" Android: layout_width = "fill_parent" Android: layout_height = "300dip" /> & Lt; LinearLayout Android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: layout_gravity = "bottom" android: gravity = "bottom" Android: orientation = "vertical" & gt; & Lt; LinearLayout Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" android: orientation = "horizontal" & gt; & Lt; Button android: id = "@ + id / ManageFiles_DeleteItem" Android: Layout_width = "Fill_parent" Android: layout_height = "40dip" Android: layout_margin = "5dip" Android: Layout_weight = "Delete 1" android: text = "before" / Gt; & Lt; Button android: id = "@ + id / ManageFiles_DeleteAll" Android: Layout_width = "Fill_parent" Android: layout_height = "40dip" Android: layout_margin = "5dip" Android: layout_weight = "1" android: text = "Delete All" / Gt; & Lt; Button android: id = "@ + id / ManageFiles_DisplayItem" Android: Layout_width = "Fill_parent" Android: layout_height = "40dip" Android: layout_margin = "5dip" Android: layout_weight = "1" android: text = "display items" / Gt; & Lt; / LinearLayout & gt; & Lt; LinearLayout Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" android: orientation = "horizontal" & gt; & Lt; Android: layout_margin = "10dip" Android: layout_weight = "1" Android: text = "OK" /> android: id = "@ + id / ManageFiles_OKcustom" Android: layout_width = "fill_parent" android: layout_height = "40dip" Gt; & Lt; Android: layout_margin = "10dip" Android: layout_weight = "1" Android: Text = "Cancel" / "Android" Gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;   

`

You can try something as simple <> pre & lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: orientation = "vertical" & gt; & Lt; Spinner Android: id = "@ + id / spinner1" Android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignParentTop = "true" android: layout_centerHorizontal = "true" /> & Lt; ListView android: id = "@ + id / listView1" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" Android: layout_alignParentLeft = "true" Android: layout_below = "@ id / spinner1" Android: layout_above = "@ + ID / Button 1 "& gt; & Lt; / ListView & gt; & Lt; Button android: id = "@ id / Button1" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: layout_alignParentBottom = "true" Android: layout_alignParentLeft = "true" android: text = "Button1" / & gt; & Lt; Button android: id = "@ id / Button1" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: layout_alignParentBottom = "true" Android: layout_alignParentRight = "true" android: text = "Button2" / & gt;

The trick is to use LinearLayout instead of RelativeLayout.

No comments:

Post a Comment