List of usage examples for android.view View getScrollX
public final int getScrollX()
From source file:org.telegram.ui.GroupCreateActivity.java
public Emoji.XImageSpan createAndPutChipForUser(TLRPC.User user) { LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View textView = lf.inflate(R.layout.group_create_bubble, null); TextView text = (TextView) textView.findViewById(R.id.bubble_text_view); text.setText(Utilities.formatName(user.first_name, user.last_name)); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(spec, spec);/* www .j ava 2 s .c o m*/ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); final BitmapDrawable bmpDrawable = new BitmapDrawable(b); bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight()); SpannableStringBuilder ssb = new SpannableStringBuilder(""); Emoji.XImageSpan span = new Emoji.XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE); allSpans.add(span); selectedContacts.put(user.id, span); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } userSelectEditText.setText(ssb); userSelectEditText.setSelection(ssb.length()); return span; }
From source file:com.aretha.slidemenu.SlideMenu.java
protected final boolean canScroll(View v, int dx, int x, int y) { if (null == mScrollDetector) { return false; }// ww w. j av a 2s. com if (v instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int childCount = viewGroup.getChildCount(); for (int index = 0; index < childCount; index++) { View child = viewGroup.getChildAt(index); final int left = child.getLeft(); final int top = child.getTop(); if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top && y + scrollY < child.getBottom() && (mScrollDetector.isScrollable(child, dx, x + scrollX - left, y + scrollY - top) || canScroll(child, dx, x + scrollX - left, y + scrollY - top))) { return true; } } } return ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.gdgl.util.SlideMenu.java
/** * Detect whether the views inside content are slidable *///from ww w.j a v a2s . c om protected final boolean canScroll(View v, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int childCount = viewGroup.getChildCount(); for (int index = 0; index < childCount; index++) { View child = viewGroup.getChildAt(index); final int left = child.getLeft(); final int top = child.getTop(); if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top && y + scrollY < child.getBottom() && View.VISIBLE == child.getVisibility() && (ScrollDetectors.canScrollHorizontal(child, dx) || canScroll(child, dx, x + scrollX - left, y + scrollY - top))) { return true; } } } return ViewCompat.canScrollHorizontally(v, -dx); }
From source file:uk.ac.kent.jb509.shopper.utils.SlidingUpPanelLayout.java
/** * Tests scrollability within child views of v given a delta of dx. * /* www. ja v a 2 s. com*/ * @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(final View v, final boolean checkV, final int dx, final int x, final 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--) { 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 && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java
/** * 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).//from w w w . java 2 s .co m * @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--) { 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 && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.base.view.slidemenu.SlideMenu.java
protected final boolean canScrollVertically(View v, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int childCount = viewGroup.getChildCount(); for (int index = 0; index < childCount; index++) { View child = viewGroup.getChildAt(index); final int left = child.getLeft(); final int top = child.getTop(); if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top && y + scrollY < child.getBottom() && View.VISIBLE == child.getVisibility() && (ScrollDetectors.canScrollVertical(child, dy) || canScrollVertically(child, dy, x + scrollX - left, y + scrollY - top))) { return true; }// w w w . j a v a 2 s . c o m } } return ViewCompat.canScrollVertically(v, -dy); }
From source file:com.base.view.slidemenu.SlideMenu.java
/** * Detect whether the views inside content are slidable *///from w w w.j ava2s.c o m protected final boolean canScrollHorizontally(View v, int dx, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int childCount = viewGroup.getChildCount(); for (int index = 0; index < childCount; index++) { View child = viewGroup.getChildAt(index); final int left = child.getLeft(); final int top = child.getTop(); if (x + scrollX >= left && x + scrollX < child.getRight() && y + scrollY >= top && y + scrollY < child.getBottom() && View.VISIBLE == child.getVisibility() && (ScrollDetectors.canScrollHorizontal(child, dx) || canScrollHorizontally(child, dx, x + scrollX - left, y + scrollY - top))) { return true; } } } return ViewCompat.canScrollHorizontally(v, -dx); }
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
/** * 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/*from w ww . j a va 2 s .c o m*/ * @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--) { 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 && ViewCompat.canScrollHorizontally(v, -dx); }
From source file:com.taobao.weex.ui.component.WXComponent.java
/** * This method computes user visible left-top point in view's coordinate. * The default implementation uses the scrollX and scrollY of the view as the result, * and put the value in the parameter pointer. * Components with different computation algorithm * <strong> should override </strong> this method. * * @param pointF the user visible left-top point in view's coordinate. *//*from w w w . ja v a 2 s .c o m*/ public void computeVisiblePointInViewCoordinate(PointF pointF) { View view = getRealView(); pointF.set(view.getScrollX(), view.getScrollY()); }
From source file:com.yahala.ui.GroupCreateActivity.java
public XImageSpan createAndPutChipForUser(TLRPC.User user) { LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View textView = lf.inflate(R.layout.group_create_bubble, null); TextView text = (TextView) textView.findViewById(R.id.bubble_text_view); String name = Utilities.formatName(user.first_name, user.last_name); if (name.length() == 0 && user.phone != null && user.phone.length() != 0) { name = PhoneFormat.getInstance().format("+" + user.phone); }/*from ww w .java 2s.co m*/ text.setText(name + ", "); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(spec, spec); textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); final BitmapDrawable bmpDrawable = new BitmapDrawable(b); bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight()); SpannableStringBuilder ssb = new SpannableStringBuilder(""); XImageSpan span = new XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE); allSpans.add(span); selectedContacts.put(user.jid, span); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } userSelectEditText.setText(ssb); userSelectEditText.setSelection(ssb.length()); return span; }