Java Code Examples for android.support.design.widget.CoordinatorLayout#getChildCount()
The following examples show how to use
android.support.design.widget.CoordinatorLayout#getChildCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BottomBehavior.java From v9porn with MIT License | 6 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) { parent.onLayoutChild(child, layoutDirection); if (isFirst) { isFirst = false; if (oLy == 0) { oLy = child.getY() + child.getHeight(); } for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); if (view instanceof AppBarLayout) { height = view.getMeasuredHeight(); break; } } child.setY(oLy); } return true; }
Example 2
Source File: BottomBehavior.java From v9porn with MIT License | 6 votes |
@Override public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) { parent.onLayoutChild(child, layoutDirection); if (isFirst) { isFirst = false; if (oLy == 0) { oLy = child.getY() + child.getHeight(); } for (int i = 0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); if (view instanceof AppBarLayout) { height = view.getMeasuredHeight(); break; } } child.setY(oLy); } return true; }
Example 3
Source File: ScrollAwareFABBehavior.java From Nibo with MIT License | 6 votes |
/** * Define one of the point in where the FAB should be hide when it reachs that point. * @param coordinatorLayout container of BottomSheet and AppBarLayout */ private void setOffsetValue(CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof AppBarLayout) { if (child.getTag() != null && child.getTag().toString().contentEquals("modal-appbar") ) { offset = child.getY()+child.getHeight(); break; } } } }
Example 4
Source File: ScrollAwareFABBehavior.java From Nibo with MIT License | 6 votes |
/** * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike} * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike} */ private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof NestedScrollView) { try { BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child); mBottomSheetBehaviorRef = new WeakReference<>(temp); break; } catch (IllegalArgumentException e){} } } }
Example 5
Source File: BackdropBottomSheetBehavior.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior} * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior} */ private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof NestedScrollView) { try { RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child); mBottomSheetBehaviorRef = new WeakReference<>(temp); break; } catch (IllegalArgumentException e){} } } }
Example 6
Source File: ScrollAwareFABBehavior.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Define one of the point in where the FAB should be hide when it reachs that point. * @param coordinatorLayout container of BottomSheet and AppBarLayout */ private void setOffsetValue(CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof AppBarLayout) { if (child.getTag() != null && child.getTag().toString().contentEquals("modal-appbar") ) { offset = child.getY()+child.getHeight(); break; } } } }
Example 7
Source File: ScrollAwareFABBehavior.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior} * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior} */ private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof NestedScrollView) { try { RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child); mBottomSheetBehaviorRef = new WeakReference<>(temp); break; } catch (IllegalArgumentException e){} } } }
Example 8
Source File: MergedAppBarLayoutBehavior.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior} * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior} */ private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof NestedScrollView) { try { RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child); mBottomSheetBehaviorRef = new WeakReference<>(temp); break; } catch (IllegalArgumentException e){} } } }
Example 9
Source File: ScrollingAppBarLayoutBehavior.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior} * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior} */ private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) { for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { View child = coordinatorLayout.getChildAt(i); if (child instanceof NestedScrollView) { try { RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child); mBottomSheetBehaviorRef = new WeakReference<>(temp); break; } catch (IllegalArgumentException e){} } } }
Example 10
Source File: CoordinatorLayoutManager.java From react-native-bottom-sheet-behavior with MIT License | 6 votes |
/** * Find and sets the FloatingActionButton anchor automatically * @param parent CoordinatorLayout parent view * @param child Child view from addView */ private void setFabAnchor(CoordinatorLayout parent, View child) { if (child instanceof FloatingActionButtonView) { FloatingActionButtonView fab = (FloatingActionButtonView) child; if (fab.getAutoAnchor()) { for (int i = 0; i < parent.getChildCount(); i++) { View childView = parent.getChildAt(i); if (childView instanceof BottomSheetBehaviorView) { int bottomSheetId = childView.getId(); fab.setAnchor(bottomSheetId); if (((BottomSheetBehaviorView) childView).behavior.getAnchorEnabled()) { fab.setScrollBehavior(); } fab.setAnchor(bottomSheetId); } } } // Set fab on the header view if (headerView != null) { headerView.setFabView(fab); } } }
Example 11
Source File: MyBottomBehavior.java From OpenWeatherPlus-Android with Apache License 2.0 | 5 votes |
private void updateImportantForAccessibility(boolean expanded) { if (this.viewRef != null) { ViewParent viewParent = ((View) this.viewRef.get()).getParent(); if (viewParent instanceof CoordinatorLayout) { CoordinatorLayout parent = (CoordinatorLayout) viewParent; int childCount = parent.getChildCount(); if (VERSION.SDK_INT >= 16 && expanded) { if (this.importantForAccessibilityMap != null) { return; } this.importantForAccessibilityMap = new HashMap(childCount); } for (int i = 0; i < childCount; ++i) { View child = parent.getChildAt(i); if (child != this.viewRef.get()) { if (!expanded) { if (this.importantForAccessibilityMap != null && this.importantForAccessibilityMap.containsKey(child)) { ViewCompat.setImportantForAccessibility(child, (Integer) this.importantForAccessibilityMap.get(child)); } } else { if (VERSION.SDK_INT >= 16) { this.importantForAccessibilityMap.put(child, child.getImportantForAccessibility()); } ViewCompat.setImportantForAccessibility(child, 4); } } } if (!expanded) { this.importantForAccessibilityMap = null; } } } }
Example 12
Source File: RefreshContentWrapper.java From CollapsingRefresh with Apache License 2.0 | 5 votes |
private void wrapperCoordinatorLayout(CoordinatorLayout layout, final RefreshLayout refreshLayout) { for (int i = layout.getChildCount() - 1; i >= 0; i--) { View view = layout.getChildAt(i); if (view instanceof AppBarLayout) { ((AppBarLayout) view).addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { mEnableRefresh = verticalOffset >= 0; mEnableLoadmore = refreshLayout.isEnableLoadmore() && (appBarLayout.getTotalScrollRange() + verticalOffset) <= 0; } }); } } }
Example 13
Source File: X5WebUtils.java From YCWebView with Apache License 2.0 | 5 votes |
/** * view转bitmap,如果是截图控件中有scrollView,那么可以取它的子控件LinearLayout或者RelativeLayout * @param v view * @return bitmap对象 */ private static Bitmap viewConversionBitmap(View v) { int w = v.getWidth(); int h = 0; if (v instanceof LinearLayout){ LinearLayout linearLayout = (LinearLayout) v; for (int i = 0; i < linearLayout.getChildCount(); i++) { h += linearLayout.getChildAt(i).getHeight(); } } else if (v instanceof RelativeLayout){ RelativeLayout relativeLayout = (RelativeLayout) v; for (int i = 0; i < relativeLayout.getChildCount(); i++) { h += relativeLayout.getChildAt(i).getHeight(); } } else if (v instanceof CoordinatorLayout){ CoordinatorLayout coordinatorLayout = (CoordinatorLayout) v; for (int i = 0; i < coordinatorLayout.getChildCount(); i++) { h += coordinatorLayout.getChildAt(i).getHeight(); } } else { h = v.getHeight(); } Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bmp); //如果不设置canvas画布为白色,则生成透明 c.drawColor(Color.WHITE); v.layout(0, 0, w, h); v.draw(c); return bmp; }
Example 14
Source File: SlidingCardBehavior.java From coordinated-effort with MIT License | 5 votes |
private SlidingCardLayout getNextChild(CoordinatorLayout parent, View child) { int cardIndex = parent.indexOfChild(child); for (int i = cardIndex + 1; i < parent.getChildCount(); i++) { View v = parent.getChildAt(i); if (v instanceof SlidingCardLayout) { return (SlidingCardLayout) v; } } return null; }
Example 15
Source File: SlidingCardBehavior.java From coordinated-effort with MIT License | 5 votes |
private int getChildMeasureOffset(CoordinatorLayout parent, View child) { //Offset is the sum of all header heights except the target int offset = 0; for (int i=0; i < parent.getChildCount(); i++) { View view = parent.getChildAt(i); if (view != child && view instanceof SlidingCardLayout) { offset += ((SlidingCardLayout) view).getHeaderHeight(); } } return offset; }