本文整理匯總了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);
}