2016-08-14 82 views
0

所以,我试图建立这个屏幕有2个listviews和一个gridview,我想要的是,一旦我开始滚动底部listview它应该移动所有元素上滚,而不是单个滚动。 Screenshot of Layout从一个特定的元素滚动到最后[Android]

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 


<ListView 
    android:id="@+id/listview1" 
    android:layout_width="fill_parent" 
    android:layout_height="200sp" /> 

<GridView 
    android:numColumns="auto_fit" 
    android:gravity="center" 
    android:columnWidth="100dp" 
    android:stretchMode="columnWidth" 
    android:layout_width="fill_parent" 
    android:layout_height="110sp" 
    android:id="@+id/grid" 
    android:horizontalSpacing="5dp" 
    android:verticalSpacing="-27dp" 
    android:layout_below="@+id/listview1" 
    android:layout_weight="0.37" /> 
     <ListView 
      android:layout_width="wrap_content" 
      android:layout_height="500dp" 
      android:id="@+id/lvScribe" 
      android:layout_below="@+id/grid" /> 
<com.ashokvarma.bottomnavigation.BottomNavigationBar 
    android:layout_gravity="bottom" 
    android:id="@+id/bottom_navigation_bar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 




</RelativeLayout> 

回答

0

假设你知道什么时候该列表的数据发生了变化,您可以手动告诉列表由列表选择设置为最后一排滚动至底部。 请按照您的要求使用此代码

private void scrolListView() { 
    myListView.post(new Runnable() { 
     @Override 
     public void run() { 
      // Select the last row so it will scroll into view... 
      myListView.setSelection(myListAdapter.getCount() - 1); 
     } 
    }); 
} 
相关问题