The screen will push to bottom in ScrollView when I add a listview in android -


i working on listview can expandable ,that means include listview in scrollview, different listview default behavior , listview height actual size , , scroll through scroll view instead of listview. below code implementation , problem , when listview expand screen push bottom, how can keep screen view @ top? thanks

listadapter customadapter = new leadersadapter(this,r.layout.leader_record_row, records);         results.setadapter(customadapter);         updatelistviewheight(results);  public static void updatelistviewheight(listview mylistview) {          listadapter mylistadapter = mylistview.getadapter();          if (mylistadapter == null) {                               return;          }         //get listview height         int totalheight = 0;         int adaptercount = mylistadapter.getcount();         (int size = 0; size < adaptercount ; size++) {             view listitem = mylistadapter.getview(size, null, mylistview);             listitem.measure(0, 0);             totalheight += listitem.getmeasuredheight();         }         //change height of listview          viewgroup.layoutparams params = mylistview.getlayoutparams();         params.height = totalheight + (mylistview.getdividerheight() * (adaptercount - 1));         mylistview.setlayoutparams(params);     } 

xml:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/share_bg" >      <scrollview         android:layout_width="match_parent"         android:layout_height="wrap_content" >          <relativelayout             android:layout_width="match_parent"             android:layout_height="wrap_content" >              <relativelayout                 android:id="@+id/lbd_top_section"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content" >                  <imageview                     android:id="@+id/lbd_logo"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignparentleft="true"                     android:layout_centervertical="true"                     android:layout_marginleft="10dp"                     android:layout_marginright="10dp" />                  <relativelayout                     android:id="@+id/lbd_my_info"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_centervertical="true"                     android:layout_torightof="@+id/lbd_logo" >                      <imageview                         android:id="@+id/lbd_user_pic"                         android:layout_width="50dp"                         android:layout_height="50dp"/>                      <textview                         android:id="@+id/lbd_user_name"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:layout_alignparentright="true"                         android:layout_aligntop="@+id/lbd_user_pic"                         android:paddingtop="5dp"                         android:layout_torightof="@+id/lbd_user_pic"                         android:textcolor="@android:color/white" />                      <textview                         android:id="@+id/lbd_user_pt"                         android:layout_width="wrap_content"                         android:layout_height="wrap_content"                         android:layout_below="@+id/lbd_user_name"                         android:layout_torightof="@+id/lbd_user_pic"                         android:textcolor="@color/dark_orange" />                 </relativelayout>             </relativelayout>              <textview                 android:id="@+id/lbd_name_tag"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignparentleft="true"                 android:layout_below="@+id/lbd_top_section"                 android:layout_marginleft="20dp"                 android:text="@string/leader_board_name"                 android:textcolor="@android:color/white"                 android:textsize="20sp" />              <textview                 android:id="@+id/lbd_pt_tag"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignparentright="true"                 android:layout_aligntop="@+id/lbd_name_tag"                 android:layout_marginright="20dp"                 android:text="@string/leader_board_pt"                 android:textcolor="@android:color/white"                 android:textsize="20sp" />              <listview                 android:id="@+id/lbd_listview"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_alignparentbottom="true"                 android:layout_below="@+id/lbd_name_tag" >             </listview>         </relativelayout>     </scrollview>  </relativelayout> 


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -