List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.ayuget.redface.ui.activity.ReplyActivity.java
private void styleToolbarButtons(ViewGroup toolbar) { for (int i = 0; i < toolbar.getChildCount(); i++) { View childView = toolbar.getChildAt(i); if (childView instanceof ImageButton) { ImageButton imageButton = (ImageButton) childView; UiUtils.setDrawableColor(imageButton.getDrawable(), UiUtils.getReplyToolbarIconsColor(this)); } else if (childView instanceof HorizontalScrollView || childView instanceof LinearLayout) { styleToolbarButtons((ViewGroup) childView); }/* w ww .j av a 2s. co m*/ } }
From source file:com.commonsware.cwac.crossport.design.widget.BottomSheetBehavior.java
@VisibleForTesting View findScrollingChild(View view) { if (ViewCompat.isNestedScrollingEnabled(view)) { return view; }/*from www. j a va 2 s. c o m*/ if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
From source file:com.efan.notlonely_android.view.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (allowWidthFull && tabsLayout != null) { View childView;//from w ww .ja v a 2s .co m for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { childView = tabsLayout.getChildAt(w); ViewGroup.LayoutParams params = childView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; childView.setLayoutParams(params); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return; } ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null) { return; } if (tabsLayout.getChildCount() <= 0) { return; } if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.ndn.menurandom.ImageDownloader.java
private void makeFrameLayout(ImageView imageView) { boolean isExist = false; ViewGroup vg = (ViewGroup) imageView.getParent(); if (vg instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) vg; String tag = (String) frameLayout.getTag(); if (tag != null && tag.equals("fl_imagedownloader")) { isExist = true;//from www .j a v a2 s . co m } } if (!isExist) { int childCount = vg.getChildCount(); int index = 0; while (index < childCount) { if (imageView == vg.getChildAt(index)) { break; } index++; } vg.removeViewAt(index); FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext()); frameLayout.setTag("fl_imagedownloader"); ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams(); frameLayout.setLayoutParams(lpImageView); imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height)); frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(), imageView.getPaddingRight(), imageView.getPaddingBottom()); imageView.setPadding(0, 0, 0, 0); frameLayout.addView(imageView); vg.addView(frameLayout, index); ProgressBar progressBar = new ProgressBar(frameLayout.getContext()); progressBar.setTag("pb_imagedownloader"); int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2; int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2; progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding); frameLayout.addView(progressBar); } }
From source file:com.juick.android.JuickMessagesAdapter.java
public static View findViewForCoordinates(ViewGroup view, float x, float y) { int childCount = view.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { View child = view.getChildAt(i); child.getHitRect(hitRect);// ww w .ja v a 2 s . co m if (hitRect.top < y && hitRect.top + hitRect.bottom > y && hitRect.left < x && hitRect.right > x) { View retval = null; if (child instanceof ViewGroup) { retval = findViewForCoordinates((ViewGroup) child, x - hitRect.left, y - hitRect.top); } if (retval == null) retval = child; return retval; } } return null; }
From source file:com.matcontrol.control.BottomSheetBehavior_v25.java
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; }// w ww . j ava 2s.com if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java
private boolean canChildrenScrollUp(View view, MotionEvent event) { if (view instanceof ViewGroup) { final ViewGroup viewgroup = (ViewGroup) view; int count = viewgroup.getChildCount(); for (int i = 0; i < count; ++i) { View child = viewgroup.getChildAt(i); Rect bounds = new Rect(); child.getHitRect(bounds);//from ww w . j av a2 s . c om if (bounds.contains((int) event.getX(), (int) event.getY())) { return canViewScrollUp(child, event); } } } return false; }
From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java
private boolean canChildrenScrollHorizontally(View view, MotionEvent event, int direction) { if (view instanceof ViewGroup) { final ViewGroup viewgroup = (ViewGroup) view; int count = viewgroup.getChildCount(); for (int i = 0; i < count; ++i) { View child = viewgroup.getChildAt(i); Rect bounds = new Rect(); child.getHitRect(bounds);// w w w. j av a 2 s .c om if (bounds.contains((int) event.getX(), (int) event.getY())) { if (DEBUG) Log.d(TAG, "in child " + child.getClass().getName()); return canViewScrollHorizontally(child, event, direction); } } } return false; }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private HashMap<Integer, String> processStickerAnnotations(ViewGroup viewGroup) { HashMap<Integer, String> allStickerAnnotations = new HashMap<>(); if (viewGroup != null) { for (int i = 0; i < viewGroup.getChildCount(); ++i) { View child = viewGroup.getChildAt(i); if (child instanceof StickerAnnotationImageView) { StickerAnnotationImageView stickerAnnotationImageView = (StickerAnnotationImageView) child; int annotationImageResource = stickerAnnotationImageView.getImageResourceId(); float getX = child.getX(); float getY = child.getY(); int width = child.getWidth(); int height = child.getHeight(); float rotation = child.getRotation(); String value = annotationImageResource + Utils.SEPARATOR + getX + Utils.SEPARATOR + getY + Utils.SEPARATOR + width + Utils.SEPARATOR + height + Utils.SEPARATOR + rotation; allStickerAnnotations.put(i, value); }/* ww w . j a v a 2 s.c o m*/ } } return allStickerAnnotations; }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private HashMap<Integer, String> processTextAnnotations(ViewGroup viewGroup) { HashMap<Integer, String> allTextAnnotations = new HashMap<>(); if (viewGroup != null) { for (int i = 0; i < viewGroup.getChildCount(); ++i) { View child = viewGroup.getChildAt(i); if (child instanceof TextAnnotationImageView) { TextAnnotationImageView textAnnotationView = (TextAnnotationImageView) child; int key = Integer.valueOf(textAnnotationView.getAnnotationNumberView().getText().toString()); // If no text was entered, just set the empty string String annotationInputText = ""; if (textAnnotationView.getAnnotationInputText() != null) { annotationInputText = (textAnnotationView.getAnnotationInputText()).trim(); }/*from w w w. j ava 2s .c o m*/ int annotationImageResource = textAnnotationView.getImageResourceId(); float getX = child.getX(); float getY = child.getY(); String value = annotationInputText + Utils.SEPARATOR + annotationImageResource + Utils.SEPARATOR + getX + Utils.SEPARATOR + getY; allTextAnnotations.put(key, value); } } } return allTextAnnotations; }