2016-08-14 77 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); 
     } 
    }); 
} 
相關問題