List of usage examples for android.widget ListView smoothScrollBy
public void smoothScrollBy(int distance, int duration)
From source file:com.juick.android.ThreadFragment.java
public void scrollMessages(int delta) { String scollMode = sp.getString("keyScrollMode", "page"); ListView lv = getListView(); if (lv.getChildCount() == 1 && scollMode.equals("message")) scollMode = "page"; if (scollMode.equals("message")) { int firstVisiblePosition = lv.getFirstVisiblePosition(); if (delta == +1) { if (firstVisiblePosition == 0) { firstVisiblePosition++; // list separator }/*from w w w. ja va2 s. co m*/ lv.setSelection(firstVisiblePosition + 1); } else { if (firstVisiblePosition != 0) { lv.setSelection(firstVisiblePosition - 1); } } } if (scollMode.equals("page")) { if (delta == +1) { lv.smoothScrollBy((int) (lv.getHeight() * 0.93), 200); } else { lv.smoothScrollBy(-(int) (lv.getHeight() * 0.93), 200); } } }
From source file:com.juick.android.MessagesFragment.java
public void scrollMessages(int delta) { if (getActivity() == null) return;//from ww w. ja v a2 s . co m if (sp == null) sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); String scollMode = sp.getString("keyScrollMode", "page"); ListView lv = getListView(); if (lv == null) return; if (lv.getChildCount() == 1 && scollMode.equals("message")) scollMode = "page"; if (scollMode.equals("message")) { int firstVisiblePosition = lv.getFirstVisiblePosition(); if (delta == +1) { lv.setSelection(firstVisiblePosition + 1); } else { if (firstVisiblePosition != 0) { lv.setSelection(firstVisiblePosition - 1); } } } if (scollMode.equals("page")) { if (delta == +1) { lv.smoothScrollBy((int) (lv.getHeight() * 0.93), 200); } else { lv.smoothScrollBy(-(int) (lv.getHeight() * 0.93), 200); } } }