本文整理匯總了Java中android.widget.AbsListView.smoothScrollBy方法的典型用法代碼示例。如果您正苦於以下問題:Java AbsListView.smoothScrollBy方法的具體用法?Java AbsListView.smoothScrollBy怎麽用?Java AbsListView.smoothScrollBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.smoothScrollBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scrollListBy
import android.widget.AbsListView; //導入方法依賴的package包/類
protected static void scrollListBy(@NonNull AbsListView listView, int y) {
if (Build.VERSION.SDK_INT >= 19) {
// Call the framework version directly
listView.scrollListBy(y);
} else if (listView instanceof ListView) {
// provide backport on earlier versions
final int firstPosition = listView.getFirstVisiblePosition();
if (firstPosition == ListView.INVALID_POSITION) {
return;
}
final View firstView = listView.getChildAt(0);
if (firstView == null) {
return;
}
final int newTop = firstView.getTop() - y;
((ListView) listView).setSelectionFromTop(firstPosition, newTop);
} else {
listView.smoothScrollBy(y, 0);
}
}
示例2: scrollback
import android.widget.AbsListView; //導入方法依賴的package包/類
private void scrollback(int offset) {
View child = mContentView.getContentView();
if (child instanceof AbsListView) {
AbsListView absListView = (AbsListView) child;
absListView.smoothScrollBy(offset, 0);
}
}