Java Code Examples for android.view.View.scrollBy()

The following are Jave code examples for showing how to use scrollBy() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SmoothRefreshLayout   File: HorizontalScrollCompat.java   Source Code and License Vote up 7 votes
public static boolean scrollCompat(View view, float deltaY) {
    if (view != null) {
        if ((view instanceof WebView)
                || (view instanceof HorizontalScrollView)) {
            view.scrollBy((int) deltaY, 0);
        } else {
            try {
                if (view instanceof RecyclerView) {
                    view.scrollBy((int) deltaY, 0);
                    return true;
                }
            } catch (NoClassDefFoundError e) {
                //ignore exception
            }
        }
    }
    return false;
}
 
Example 2
Project: GitHub   File: ScrollingUtil.java   Source Code and License Vote up 6 votes
public static void scrollAViewBy(View view, int height) {
    if (view instanceof RecyclerView) ((RecyclerView) view).smoothScrollBy(0, height);
    else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height);
    else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 150);
    else {
        try {
            Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
            method.invoke(view, 0, height);
        } catch (Exception e) {
            view.scrollBy(0, height);
        }
    }
}
 
Example 3
Project: LuaViewPlayground   File: UDView.java   Source Code and License Vote up 6 votes
/**
 * 滚动dx, dy
 *
 * @param dx
 * @param dy
 * @return
 */
public UDView scrollBy(final int dx, final int dy) {
    final View view = getView();
    if (view != null) {
        view.scrollBy(dx, dy);
    }
    return this;
}
 
Example 4
Project: AgentWebX5   File: ScrollingUtil.java   Source Code and License Vote up 6 votes
public static void scrollAViewBy(View view, int height) {
    if (view instanceof RecyclerView) ((RecyclerView) view).scrollBy(0, height);
    else if (view instanceof ScrollView) ((ScrollView) view).smoothScrollBy(0, height);
    else if (view instanceof AbsListView) ((AbsListView) view).smoothScrollBy(height, 0);
    else {
        try {
            Method method = view.getClass().getDeclaredMethod("smoothScrollBy", Integer.class, Integer.class);
            method.invoke(view, 0, height);
        } catch (Exception e) {
            view.scrollBy(0, height);
        }
    }
}