Java Code Examples for android.support.design.widget.CoordinatorLayout#getChildAt()
The following examples show how to use
android.support.design.widget.CoordinatorLayout#getChildAt() .
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: 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 3
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 4
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 5
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 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: 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 8
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 9
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 10
Source File: RecyclerViewBehavior.java From timecat with Apache License 2.0 | 6 votes |
@Override public void onStopNestedScroll(final CoordinatorLayout parent, final RecyclerView child, View target) { // Log.e("ldf", "onStopNestedScroll"); super.onStopNestedScroll(parent, child, target); MonthPager monthPager = (MonthPager) parent.getChildAt(0); monthPager.setScrollable(true); if (!Utils.isScrollToBottom()) { if (initOffset - Utils.loadTop() > Utils.getTouchSlop(context) && hidingTop) { Utils.scrollTo(parent, child, getMonthPager(parent).getCellHeight(), 500); } else { Utils.scrollTo(parent, child, getMonthPager(parent).getViewHeight(), 150); } } else { if (Utils.loadTop() - minOffset > Utils.getTouchSlop(context) && showingTop) { Utils.scrollTo(parent, child, getMonthPager(parent).getViewHeight(), 500); } else { Utils.scrollTo(parent, child, getMonthPager(parent).getCellHeight(), 150); } } }
Example 11
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 12
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; }
Example 13
Source File: RecyclerViewBehavior.java From timecat with Apache License 2.0 | 5 votes |
@Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, RecyclerView child, View directTargetChild, View target, int nestedScrollAxes) { // Log.e("ldf", "onStartNestedScroll"); MonthPager monthPager = (MonthPager) coordinatorLayout.getChildAt(0); monthPager.setScrollable(false); boolean isVertical = (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; return isVertical; }
Example 14
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 15
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 16
Source File: SlidingCardBehavior.java From coordinated-effort with MIT License | 5 votes |
private SlidingCardLayout getPreviousChild(CoordinatorLayout parent, View child) { int cardIndex = parent.indexOfChild(child); for (int i = cardIndex - 1; i >= 0; i--) { View v = parent.getChildAt(i); if (v instanceof SlidingCardLayout) { return (SlidingCardLayout) v; } } return null; }
Example 17
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 18
Source File: RecyclerViewBehavior.java From timecat with Apache License 2.0 | 4 votes |
private MonthPager getMonthPager(CoordinatorLayout coordinatorLayout) { return (MonthPager) coordinatorLayout.getChildAt(0); }
Example 19
Source File: CommonPtrLayout.java From FamilyChat with Apache License 2.0 | 4 votes |
/** * 通过id得到相应的view */ @Override protected void onFinishInflate() { final int childCount = getChildCount(); if (childCount > 0) { mRefreshView = findViewById(com.lib.ptrview.R.id.common_ptrview_refresh_view); mContentView = findViewById(com.lib.ptrview.R.id.common_ptrview_content); mLoadMoreView = findViewById(com.lib.ptrview.R.id.common_ptrview_loadmore_view); mScrollContentView = findViewById(com.lib.ptrview.R.id.common_ptrview_content_scroll); } if (mContentView == null) { throw new IllegalStateException("CommonPtrLayout: mContentView is null"); } if (mIsCoo) { if (mContentView instanceof CoordinatorLayout) { CoordinatorLayout coo = (CoordinatorLayout) mContentView; mAppBar = (AppBarLayout) coo.getChildAt(0); setAppBarListener(); } else { throw new IllegalStateException("CommonPtrLayout: mContentView is not CoordinatorLayout"); } if (mScrollContentView == null) { throw new IllegalStateException("CommonPtrLayout: mScrollContentView is null"); } if (!(mScrollContentView instanceof NestedScrollingChild)) { throw new IllegalStateException("CommonPtrLayout: mScrollContentView is not NestedScrollingChild"); } } if (mRefreshEnabled) { if (mRefreshView == null) throw new IllegalStateException("CommonPrtLayout : You must set a refreshView when the refreshEnabled is true."); if (!(mRefreshView instanceof CommonPtrViewImpl)) throw new IllegalStateException("CommonPrtLayout : The refreshView must instanceof CommonPtrViewImpl."); mRefreshView.setBackgroundResource(mRefreshBgResId); getRefreshView().setIsPullDownMode(true); } if (mLoadMoreEnabled) { if (mLoadMoreView == null) throw new IllegalStateException("CommonPrtLayout : You must set a loadMoreView when the refreshEnabled is true."); if (!(mLoadMoreView instanceof CommonPtrViewImpl)) throw new IllegalStateException("CommonPrtLayout : The loadMoreView must instanceof CommonPtrViewImpl."); mLoadMoreView.setBackgroundResource(mLoadMoreBgResId); getLoadMoreView().setIsPullDownMode(false); } super.onFinishInflate(); for (int i = 0; i < childCount; i++) { View v = getChildAt(i); if (v != mContentView) bringChildToFront(v); } }
Example 20
Source File: CanRefreshLayout.java From CanRefresh with Apache License 2.0 | 2 votes |
/** * 通过id得到相应的view */ @Override protected void onFinishInflate() { final int childCount = getChildCount(); if (childCount > 0) { mHeaderView = findViewById(com.canyinghao.canrefresh.R.id.can_refresh_header); mContentView = findViewById(com.canyinghao.canrefresh.R.id.can_content_view); mFooterView = findViewById(com.canyinghao.canrefresh.R.id.can_refresh_footer); mScrollView = findViewById(com.canyinghao.canrefresh.R.id.can_scroll_view); } if (mContentView == null) { throw new IllegalStateException("mContentView is null"); } if (mIsCoo) { if (mContentView instanceof CoordinatorLayout) { CoordinatorLayout coo = (CoordinatorLayout) mContentView; mAppBar = (AppBarLayout) coo.getChildAt(0); setAppBarListener(); } else { throw new IllegalStateException("mContentView is not CoordinatorLayout"); } if (mScrollView == null) { throw new IllegalStateException("mScrollView is null"); } if (mScrollView instanceof ViewPager) { mViewPager = (ViewPager) mScrollView; mIsViewPager = true; } else if (mScrollView instanceof NestedScrollingChild) { mIsViewPager = false; } else { throw new IllegalStateException("mScrollView is not NestedScrollingChild or ViewPager"); } } if (mHeaderView != null && !(mHeaderView instanceof CanRefresh)) { throw new IllegalStateException("mHeaderView error"); } if (mFooterView != null && !(mFooterView instanceof CanRefresh)) { throw new IllegalStateException("mFooterView error"); } if (mHeaderView != null) { getHeaderInterface().setIsHeaderOrFooter(true); } if (mFooterView != null) { getFooterInterface().setIsHeaderOrFooter(false); } super.onFinishInflate(); setStyle(mHeadStyle, mFootStyle); }