当前位置: 首页>>代码示例>>Java>>正文


Java ScrollView.getChildCount方法代码示例

本文整理汇总了Java中android.widget.ScrollView.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollView.getChildCount方法的具体用法?Java ScrollView.getChildCount怎么用?Java ScrollView.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ScrollView的用法示例。


在下文中一共展示了ScrollView.getChildCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScrollViewBitmap

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * 截取scrollview的屏幕
 **/
public static Bitmap getScrollViewBitmap(ScrollView scrollView) {
    int h = 0;
    Bitmap bitmap;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
    }
    // 创建对应大小的bitmap

    bitmap = Bitmap.createBitmap(ScreenUtils.getScreenWidth(), h,
            Bitmap.Config.ARGB_4444);
    final Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(Color.parseColor("#f2f7fa"));
    scrollView.draw(canvas);
    return bitmap;
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:19,代码来源:LongImageUtils.java

示例2: computeVerticalScrollRange

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * Copy From ScrollView (API Level >= 14)
 * <p>The scroll range of a scroll view is the overall height of all of its
 * children.</p>
 */
private int computeVerticalScrollRange(ScrollView scrollView) {
    final int count = scrollView.getChildCount();
    final int contentHeight = scrollView.getHeight() - scrollView.getPaddingBottom() - scrollView.getPaddingTop();
    if (count == 0) {
        return contentHeight;
    }

    int scrollRange = scrollView.getChildAt(0).getBottom();
    final int scrollY = scrollView.getScrollY();
    final int overScrollBottom = Math.max(0, scrollRange - contentHeight);
    if (scrollY < 0) {
        scrollRange -= scrollY;
    } else if (scrollY > overScrollBottom) {
        scrollRange += scrollY - overScrollBottom;
    }

    return scrollRange;
}
 
开发者ID:stytooldex,项目名称:pius1,代码行数:24,代码来源:SlideBottomPanel.java

示例3: onCreate

import android.widget.ScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("ScrollView");
    setContentView(R.layout.scroll_view_layout);
    final ScrollView scrollView = (ScrollView) findViewById(R.id.container);
    final int childCount = scrollView.getChildCount();
    LogUtil.d(" scroll view child count : " + childCount);
    scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {

        int oldScrollY = 0;

        @Override
        public void onScrollChanged() {
            LogUtil.d("ScrollView scroll changed  scroll view : " + (scrollView.getScrollY() - oldScrollY));
            oldScrollY = scrollView.getScrollY();
            LogUtil.d("Height : " + scrollView.getHeight());
        }
    });
}
 
开发者ID:anmingyu11,项目名称:OverScrollableRecyclerView-Method1,代码行数:21,代码来源:ScrollViewActivity.java

示例4: canChildScrollDown

import android.widget.ScrollView; //导入方法依赖的package包/类
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:22,代码来源:PtrDefaultHandler2.java

示例5: saveScrollViewToBitmap

import android.widget.ScrollView; //导入方法依赖的package包/类
private static Bitmap saveScrollViewToBitmap(ScrollView scrollView) {
    int h = 0;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
    }
    Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h,
            Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);
    scrollView.draw(canvas);
    return bitmap;
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:12,代码来源:RxImage.java

示例6: getBitmapByView

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * 截取scrollview的屏幕
 * **/
public static Bitmap getBitmapByView(ScrollView scrollView) {
	int h = 0;
	Bitmap bitmap = null;
	// 获取listView实际高度
	for (int i = 0; i < scrollView.getChildCount(); i++) {
		h += scrollView.getChildAt(i).getHeight();
	}
	// 创建对应大小的bitmap
	bitmap = Bitmap.createBitmap(scrollView.getWidth(), h,
			Bitmap.Config.ARGB_8888);
	final Canvas canvas = new Canvas(bitmap);
	scrollView.draw(canvas);
	return bitmap;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:18,代码来源:ShareUtil.java

示例7: getBitmapByView

import android.widget.ScrollView; //导入方法依赖的package包/类
public static Bitmap getBitmapByView(ScrollView scrollView) {
    int h = 0;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
    }
    Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Config.ARGB_8888);
    scrollView.draw(new Canvas(bitmap));
    return bitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:BitmapUtil.java

示例8: toBitmap

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
        LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:54,代码来源:ConvertUtils.java

示例9: toBitmap

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * 把view转化为bitmap(截图)
 * 参见:http://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    if (!bitmap.isRecycled()) {
       // LogUtils.verbose("recycle bitmap: " + bitmap.toString());
        bitmap.recycle();
    }
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:54,代码来源:ConvertUtils.java

示例10: isViewBeingDragged

import android.widget.ScrollView; //导入方法依赖的package包/类
public boolean isViewBeingDragged(MotionEvent event, ScrollView view) {
    if (view.getChildCount() == 0) {
        return true;
    }
    view.getLocationOnScreen(this.mViewLocationResult);
    int viewLeft = this.mViewLocationResult[0];
    int viewTop = this.mViewLocationResult[1];
    this.mRect.set(viewLeft, viewTop, view.getWidth() + viewLeft, view.getHeight() + viewTop);
    int rawX = (int) event.getRawX();
    int rawY = (int) event.getRawY();
    return this.mRect.contains(rawX, rawY) ? isReadyForPull(view, (float) (rawX - this.mRect
            .left), (float) (rawY - this.mRect.top)) : false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ScrollViewDelegate.java

示例11: canScrollViewScroll

import android.widget.ScrollView; //导入方法依赖的package包/类
private static boolean canScrollViewScroll(ScrollView sv) {
    if (sv.getChildCount() == 0)
        return false;
    final int childHeight = sv.getChildAt(0).getMeasuredHeight();
    return sv.getMeasuredHeight() - sv.getPaddingTop() - sv.getPaddingBottom() < childHeight;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:MDRootLayout.java

示例12: canChildScrollDown

import android.widget.ScrollView; //导入方法依赖的package包/类
public static boolean canChildScrollDown(View view) {
    if (view instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) view;
        if (Build.VERSION.SDK_INT < 14) {
            return absListView.getChildCount() == 0
                    || absListView.getAdapter() == null
                    || (absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1)
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom()
                    > absListView.getHeight() - absListView.getPaddingBottom());
        } else {
            if (Build.VERSION.SDK_INT < 26)
                return absListView.getChildCount() == 0 ||
                        ViewCompat.canScrollVertically(view, 1);
            else
                return absListView.getChildCount() == 0 ||
                        view.canScrollVertically(1);
        }
    } else if (view instanceof ScrollView) {
        final ScrollView scrollView = (ScrollView) view;
        if (Build.VERSION.SDK_INT < 14) {
            return scrollView.getChildCount() == 0
                    || (scrollView.getChildCount() != 0
                    && scrollView.getScrollY() < scrollView.getChildAt(0).getHeight()
                    - scrollView.getHeight());
        } else {
            if (Build.VERSION.SDK_INT < 26)
                return scrollView.getChildCount() == 0 ||
                        ViewCompat.canScrollVertically(view, 1);
            else
                return scrollView.getChildCount() == 0 ||
                        view.canScrollVertically(1);
        }
    } else {
        try {
            if (view instanceof RecyclerView) {
                final RecyclerView recyclerView = (RecyclerView) view;
                if (Build.VERSION.SDK_INT < 26)
                    return recyclerView.getChildCount() == 0 ||
                            ViewCompat.canScrollVertically(view, 1);
                else
                    return recyclerView.getChildCount() == 0 ||
                            view.canScrollVertically(1);
            }
        } catch (NoClassDefFoundError e) {
            e.printStackTrace();
        }
        if (Build.VERSION.SDK_INT < 26)
            return ViewCompat.canScrollVertically(view, 1);
        else
            return view.canScrollVertically(1);
    }
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:54,代码来源:ScrollCompat.java

示例13: toBitmap

import android.widget.ScrollView; //导入方法依赖的package包/类
/**
 * convert View to Bitmap.
 *
 * @param view the view
 * @return the bitmap
 * @link http ://www.cnblogs.com/lee0oo0/p/3355468.html
 */
public static Bitmap toBitmap(View view) {
    //以下代码用于把当前view转化为bitmap(截图)
    int width = view.getWidth();
    int height = view.getHeight();
    if (view instanceof ListView) {
        height = 0;
        // 获取listView实际高度
        ListView listView = (ListView) view;
        for (int i = 0; i < listView.getChildCount(); i++) {
            height += listView.getChildAt(i).getHeight();
        }
    } else if (view instanceof ScrollView) {
        height = 0;
        // 获取scrollView实际高度
        ScrollView scrollView = (ScrollView) view;
        for (int i = 0; i < scrollView.getChildCount(); i++) {
            height += scrollView.getChildAt(i).getHeight();
        }
    }
    view.setDrawingCacheEnabled(true);
    view.clearFocus();
    view.setPressed(false);
    boolean willNotCache = view.willNotCacheDrawing();
    view.setWillNotCacheDrawing(false);
    // Reset the drawing cache background color to fully transparent for the duration of this operation
    int color = view.getDrawingCacheBackgroundColor();
    view.setDrawingCacheBackgroundColor(Color.WHITE);//截图去黑色背景(透明像素)
    if (color != Color.WHITE) {
        view.destroyDrawingCache();
    }
    view.buildDrawingCache();
    Bitmap cacheBitmap = view.getDrawingCache();
    if (cacheBitmap == null) {
        return null;
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(cacheBitmap, 0, 0, null);
    canvas.save(Canvas.ALL_SAVE_FLAG);
    canvas.restore();
    cacheBitmap.recycle();
    // Restore the view
    view.destroyDrawingCache();
    view.setWillNotCacheDrawing(willNotCache);
    view.setDrawingCacheBackgroundColor(color);
    return bitmap;
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:55,代码来源:ConvertUtils.java


注:本文中的android.widget.ScrollView.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。