Android RelativeLayout and height of wrap_content? -


i trying make selection listactivity, similar 1 used add shortcuts launcher screens. have rolled own header , footers, "sticky" @ top , bottom of view when on screen. in order this, using relativelayout header set dock top, footer set dock bottom, , list set go below header , above footer. in terms of overall layout of activity, rendering expect. header sticky top, footer sticky bottom, , list scrolls in between them.

one odd thing though happened when switched relativelayout root. please see following screenshot:

enter image description here

i want activity's height wrap_content, form high content displayed in it, once switched relativelayout, seems render activity fill_parent, taking whole screen, though content doesn't warrant it. notice there not enough list items fill screen, fill_parent style, leaving bunch of whitespace between end of list, , footer. setting height's via styles - worked fine linearlayout, seems ignored now. tried hard-coding height directly on relativelayout, still doesn't work , still renders fill_parent.

here layout code:

<?xml version="1.0" encoding="utf-8"?>     <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"                      style="@style/groupslist"                       android:layout_height="wrap_content">          <framelayout android:layout_height="wrap_content"                       android:layout_width="fill_parent"                       android:id="@+id/hdrgroups"                       android:layout_alignparenttop="true">             <include layout="@layout/title"                       android:layout_width="fill_parent"                       android:layout_height="wrap_content">             </include>         </framelayout>          <framelayout style="@style/myfooter"                       android:layout_height="wrap_content"                       android:layout_width="fill_parent"                       android:layout_alignparentbottom="true"                       android:id="@+id/ftrgroups">             <imageview style="@style/closebutton"                         android:layout_height="wrap_content"                         android:layout_width="wrap_content"                         android:src="@drawable/add"                         android:id="@+id/imggroupsadd"                         android:clickable="true">             </imageview>         </framelayout>          <listview android:divider="#9f9f9f"                    android:id="@+id/android:list"                    android:choicemode="singlechoice"                    android:dividerheight="1dp"                    android:layout_height="wrap_content"                    android:layout_width="fill_parent"                    android:layout_below="@id/hdrgroups"                    android:layout_above="@id/ftrgroups">         </listview>          <textview android:text="@string/browser_no_groups"                    style="@style/listeditemb"                    android:id="@+id/android:empty"                    android:layout_height="wrap_content"                    android:layout_above="@id/ftrgroups"                    android:layout_below="@id/hdrgroups"                    android:layout_width="fill_parent">         </textview>     </relativelayout> 

all layout done via xml, ... not doing layout in code. how can sticky header , footer while having activity whole behave in wrap_content mode height? there other way should going instead of relativelayout?

according developer documentation desired behaviour not possible relative layout ;(

"note cannot have circular dependency between size of relativelayout , position of children. example, cannot have relativelayout height set wrap_content , child set align_parent_bottom. "

relativelayout

to solve problem maybe try use linear layout, set wrap_content , set max height via code screen height.

you can screen height described here get screen height


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -