2
How can I get a Listview to assemble the items as follows:
When you have only one item it occupies the entire screen, if you have two divide 50% of the screen size between the items and so on...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ListViewActivity" >
<ListView
android:id="@+id/listaromaneiosview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/Black"
android:dividerHeight="5dp"
tools:listitem="@layout/cre_004_listaromaneios_adpter" >
</ListView>
<TextView
android:id="@+id/textoListView"
android:text=""
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="3"
android:textSize="@dimen/titulo"/>
<ImageButton
android:id="@+id/selecionaRomaneio"
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_weight="1"
android:background="@color/White"
android:contentDescription="@string/app_name"
android:maxWidth="100dp"
android:onClick="actionListner"
android:src="@android:drawable/ic_menu_delete" />
Try to place their height as fill_parent.
– Trxplz0
I tried it didn’t work out, he wasn’t on the full screen..
– Marco André
Which layout are you using?
– Trxplz0
Relativelayout and Linearlayout for the list item
– Marco André
Listview needs to stay as fill_parent and the parent element of the Adapter that Textview and Imagebutton need to be as fill_parent as well. Try it this way I believe it should work!
– Trxplz0
I think this behavior is not possible, maybe you will have to do "in hand" using a
LinearLayout
and using theweight
andweightSum
of children.– Wakim