android - ListView collapse in CustomScrollView -


hello new in android development, , i've read various threads talked fact listview should not inside scrollview , need wrap in linear or relative layout.

but have layout

<com.itmind.spac.spacapp.custom_extends.customscrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scrollviewreceipt" > <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">      <include     android:id="@+id/include1"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     layout="@layout/toolbar" />      <spinner         android:id="@+id/customers_spinner"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_margintop="20dp"         android:theme="@android:style/theme.holo.light.darkactionbar"         />     <spinner         android:id="@+id/venues_spinner"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_margintop="20dp"         android:theme="@android:style/theme.holo.light.darkactionbar"         />     <spinner         android:id="@+id/workgroup_spinner"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_margintop="20dp"         android:theme="@android:style/theme.holo.light.darkactionbar"         />          <linearlayout  xmlns:android="http://schemas.android.com/apk/res/android"          android:orientation="vertical" android:layout_width="wrap_content"          android:layout_height="wrap_content"             android:minheight="150dp">     <listview         android:id="@+id/activitylist"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margintop="15dp"         android:minheight="150dp"         />     </linearlayout >      <android.gesture.gestureoverlayview         android:id="@+id/signaturepad"         android:layout_width="match_parent"         android:layout_height="80dp"         android:layout_weight="5"         android:background="#d3d3d3"         android:eventsinterceptionenabled="true"         android:fadeenabled="false"         android:gesturecolor="#333"         android:gesturestrokelengththreshold="0.1"         android:gesturestroketype="multiple"         android:fadeoffset="5000"         android:orientation="vertical" >     </android.gesture.gestureoverlayview>     <button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:onclick="testimage"         android:text="testami"/> </linearlayout> 

and custoscrollview

public class customscrollview extends scrollview {  private boolean enablescrolling = true;  public boolean isenablescrolling() {     return enablescrolling; }  public void setenablescrolling(boolean enablescrolling) {     this.enablescrolling = enablescrolling; }  public customscrollview(context context, attributeset attrs, int defstyle) {     super(context, attrs, defstyle); }  public customscrollview(context context, attributeset attrs) {     super(context, attrs); }  public customscrollview(context context) {     super(context); }  @override public boolean onintercepttouchevent(motionevent ev) {      if (isenablescrolling()) {         return super.onintercepttouchevent(ev);     } else {         return false;     } } @override public boolean ontouchevent(motionevent ev) {     if (isenablescrolling()) {         return super.ontouchevent(ev);     } else {         return false;     } } } 

i need customclass scroll view beacause can set enable scroll when touch on

so in activity implements gestureoverlayview.ongesturelistener have:

 @override public void ongesturestarted(gestureoverlayview overlay, motionevent event) {     myscrollview.setenablescrolling(false); } @override public void ongestureended(gestureoverlayview overlay, motionevent event) {     myscrollview.setenablescrolling(true); } 

so many elements , need scrollview view elements. inside scrollview have listview populate data retrieve db.

my problem listview collapse, shows 1 line , see , scroll in 1 row.

i tried min-height doesn't work, , if put layout height in listview, cant scroll list.

how can this? list view in long page have use scrollview or there solutions?

below given custom listview class make height of listview based on content inside scrollview. use instead of listview in xml-layout file same way use customscrollview.

public class customlistview extends listview {  //  private boolean expanded;      public customlistview(context context, attributeset attrs) {         super(context, attrs);     }      public customlistview(context context) {         super(context);     }      public customlistview(context context, attributeset attrs, int defstyle) {         super(context, attrs, defstyle);     }      @override     public void onmeasure(int widthmeasurespec, int heightmeasurespec) {         int expandspec = measurespec.makemeasurespec(integer.max_value >> 2,                 measurespec.at_most);         super.onmeasure(widthmeasurespec, expandspec);     } } 

hope you.

note :- per this link of android developer website, should never use scrollview listview, because listview takes care of own vertical scrolling.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -