How can i create a listview as big as it's listitems in a layout based on weights? programmaticaly?



I have a layout, it should have a listview on top thats scrollable and the listitem should be the size of the layout itself! but layout is defined with weights... and it should be like this:


what i want to achieve!


but as soon as i add the adapter with the listitems, the view gets resized! and pushes the other weight set (image)views smaller! And i can set the listitem (which is a seperate fragment) to a dynamic size (like 100dp) but then on different resolutions it won't be as big as the layout where it should fit in to..


my menulayout:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="4">
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/startmenu_lv_spotlight"
android:listSelector="@drawable/selector_view" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:weightSum="2">
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="wrap_content"
android:id="@+id/startmenu_iv_shops"
android:layout_weight="1"
android:scaleType="centerCrop"
android:layout_height="fill_parent" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="wrap_content"
android:layout_weight="1"
android:id="@+id/startmenu_iv_categories"
android:scaleType="centerCrop"
android:layout_height="fill_parent" />
</LinearLayout>
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_weight="1"
android:id="@+id/startmenu_iv_review"
android:scaleType="centerCrop"
android:layout_height="0dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:weightSum="2">
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/startmenu_iv_newmovie"
android:layout_height="fill_parent" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/startmenu_iv_personalactions"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>


and my fragment of the list item:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="match_parent"
android:weightSum="4">
<ImageView
android:id="@+id/deal_li_iv_icon_category"
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1" />
<RelativeLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="fill_parent">
<TextView
android:id="@+id/deal_li_tv_text"
android:layout_toRightOf="@id/deal_li_iv_icon_category"
android:text="text here"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>


How should i create it so that when i set the adapter, the ListView will NOT resize its bounds! and listitems will be as big as the height of the listview's bounds?


No comments:

Post a Comment