本文整理汇总了Java中android.view.View.canScrollHorizontally方法的典型用法代码示例。如果您正苦于以下问题:Java View.canScrollHorizontally方法的具体用法?Java View.canScrollHorizontally怎么用?Java View.canScrollHorizontally使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.canScrollHorizontally方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canScroll
import android.view.View; //导入方法依赖的package包/类
/**
* Tests scrollability within child views of v given a delta of dx.
*
* @param v View to test for horizontal scrollability
* @param checkV Whether the view v passed should itself be checked for scrollability (true),
* or just its children (false).
* @param dx Delta scrolled in pixels
* @param x X coordinate of the active touch point
* @param y Y coordinate of the active touch point
* @return true if child views of v can be scrolled by delta of dx.
*/
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
if (v instanceof ViewGroup) {
final ViewGroup group = (ViewGroup) v;
final int scrollX = v.getScrollX();
final int scrollY = v.getScrollY();
final int count = group.getChildCount();
// Count backwards - let topmost views consume scroll distance first.
for (int i = count - 1; i >= 0; i--) {
// TODO: Add versioned support here for transformed views.
// This will not work for transformed views in Honeycomb+
final View child = group.getChildAt(i);
if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
&& y + scrollY >= child.getTop() && y + scrollY < child.getBottom()
&& canScroll(child, true, dx, x + scrollX - child.getLeft(),
y + scrollY - child.getTop())) {
return true;
}
}
}
return checkV && v.canScrollHorizontally(-dx);
}
示例2: canChildScrollLeft
import android.view.View; //导入方法依赖的package包/类
public static boolean canChildScrollLeft(View view) {
if (Build.VERSION.SDK_INT < 26)
return ViewCompat.canScrollHorizontally(view, -1);
else
return view.canScrollHorizontally(-1);
}
示例3: canChildScrollRight
import android.view.View; //导入方法依赖的package包/类
public static boolean canChildScrollRight(View view) {
if (Build.VERSION.SDK_INT < 26)
return ViewCompat.canScrollHorizontally(view, 1);
else
return view.canScrollHorizontally(1);
}
示例4: canScrollHorizontally
import android.view.View; //导入方法依赖的package包/类
public static boolean canScrollHorizontally(View v, int direction) {
return v.canScrollHorizontally(direction);
}
示例5: isScrollToLeft
import android.view.View; //导入方法依赖的package包/类
/**
* view是否已经滚动到最左边
*
* @param view
* @return
*/
public static boolean isScrollToLeft(View view)
{
return !view.canScrollHorizontally(-1);
}
示例6: isScrollToRight
import android.view.View; //导入方法依赖的package包/类
/**
* view是否已经滚动到最右边
*
* @param view
* @return
*/
public static boolean isScrollToRight(View view)
{
return !view.canScrollHorizontally(1);
}