android - How to configure ListView to automatically change its height? -


Text after "

I have three ListView widgets in the LinearLayout . Something like this (I am leaving XML elements that are not relevant in this example):

   & Lt; ListView Android: layout_width = "fill_parent" Android: layout_height = "360dp" /> & Lt; ListView Android: layout_width = "fill_parent" Android: layout_height = "360dp" /> & Lt; / LinearLayout & gt;  

This list forces the list to keep the height of 360 dip. Of course, it will be its height even if there are some inventory items. So, my question is how can I make lists an automatic height? Do I want that ListView height takes the correct size of the sum of all of your list items.

I have implemented it in this way (code work is in progress, so compared to this solution More is an idea source):

  package com.customcontrols; Public class NoScrollListView ListView {@Override Zero onMeasure Protected Spread (integer widthMeasureSpec, integer heightMeasureSpec) {super.onMeasure (widthMeasureSpec, MeasureSpec.makeMeasureSpec (MeasureSpec.mSPECIFIED, 0)); Here // I think the height is going to be the source of ListView which is actually a bad idea in the integer childHeight = getMeasuredHeight (), only calculated for a child calculated this value - getListPaddingTop () + getListPaddingBottom () + GetVerticalFadingEdgeLength () * 2); Integer Heat = Receive List Pining () + ReceiveLittlePadtingBottom () + ChildHit * (getCount ()); Setmash dimension (friendly), full height); }}  

The calculation is not correct, but it is close and works so far. After that you just create a layout like this:

scrollview com.customcontrol.NoScrollListView com.customcontrol.NoScrollListView com.customcontrol.NoScrollListView / scrollview

since scrollview is important You can run smoothly out of the screen border.

Most of the calculation methods of PS ListView & calculate later from the rectum; Co-Private package, which is quite a strange option for UI publicly funded classes

.

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -