I have a listview in the actionbarsherlock drawer matching its full size for switching between frames. I want to align 4 listitems from the listview to the top and 3 to the bottom of the drawer. Any idea how to do it ? First idea was to calculate the space in the middle and create one empty listitem with such height. But I did not found a way how to do it. Or any better idea ?
edit1: Understood, but I want to do it in the code not xml. I have a draer_main.xml where is a LinearLayout listview. and then a drawer_list_item where I have LinearLayout in which there is specified how item looks like. This is the used in the code and for each item is written some text + added picture
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View itemView = inflater.inflate(R.layout.drawer_list_item, parent, false);
So I tried to set the itemView params as you proposed but there is always an error cause java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
edit2: Tried to use AbsListView.LayoutParams, but this has not parameter weight !?!
Simple!
Create a View
to fill the space between the top 4 listitems and the bottom 3 listitems.
Example:
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.