List of usage examples for android.widget ScrollView getChildAt
public View getChildAt(int index)
From source file:com.recyclerviewpulldownrefresh.view.refresh.AbPullToRefreshView.java
/** * ??/*from w w w. ja v a2 s. c om*/ * * @return */ public boolean canChildScrollDown() { if (!mEnableLoadMore) { return false; } if (mTarget instanceof AdapterView<?>) { AdapterView<?> absListView = (AdapterView<?>) mTarget; View lastChild = absListView.getChildAt(absListView.getChildCount() - 1); if (lastChild == null) { return true; } // ??viewBottom?ViewmAdapterView?view, // ViewmAdapterView?? if (lastChild.getBottom() <= getHeight() && absListView.getLastVisiblePosition() == absListView.getCount() - 1) { return true; } } else if (mTarget instanceof WebView) { WebView webview = (WebView) mTarget; return webview.getContentHeight() * webview.getScale() <= webview.getHeight() + webview.getScrollY(); } else if (mTarget instanceof ScrollView) { ScrollView scrollView = (ScrollView) mTarget; View childView = scrollView.getChildAt(0); if (childView != null) { return childView.getMeasuredHeight() <= getHeight() + mScrollView.getScrollY(); } } else if (mTarget instanceof RecyclerView) { int lastVisiblePosition = 0; View childView = null; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { lastVisiblePosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof GridLayoutManager) { lastVisiblePosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof StaggeredGridLayoutManager) { int[] spanPosition = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()]; ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(spanPosition); lastVisiblePosition = getLastVisibleItemPosition(spanPosition); childView = getLastVisibleItemBottomView(layoutManager, spanPosition, lastVisiblePosition); } if (null == childView) { return false; } if (lastVisiblePosition == layoutManager.getItemCount() - 1 && childView.getBottom() + layoutManager.getBottomDecorationHeight(childView) <= mTarget.getBottom()) { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } return false; }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
private void showFlashRecoveryDialog() { final Dialog FlashRecoveryDialog = new Dialog(mContext); LayoutInflater inflater = getLayoutInflater(); FlashRecoveryDialog.setTitle(R.string.flash_options); try {//from w w w . jav a2s.c o m final ScrollView RecoveryLayout = (ScrollView) inflater.inflate(R.layout.recovery_dialog, null); LinearLayout layout = (LinearLayout) RecoveryLayout.getChildAt(0); FlashRecoveryDialog.setContentView(RecoveryLayout); if (!mDevice.isCwmSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bCWM)); } if (!mDevice.isTwrpSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bTWRP)); } if (!mDevice.isPhilzSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bPHILZ)); } FlashRecoveryDialog.show(); } catch (NullPointerException e) { Notifyer.showExceptionToast(mContext, TAG, e); } }
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void startBottomBarAnimation() { final HorizontalScrollView horizontalScrollView = (HorizontalScrollView) mMainActivity .findViewById(R.id.bottom_bar_scroll_view); final ScrollView verticalScrollView = (ScrollView) mMainActivity .findViewById(R.id.bottom_bar_landscape_scroll_view); final int animationDuration = 1000; int orientation = mMainActivity.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { horizontalScrollView.post(new Runnable() { public void run() { int scrollToX = (int) (getToolButtonByToolType(mCurrentToolType).getX() - horizontalScrollView.getWidth() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_button_width) / 2.0f); int scrollFromX = PaintroidApplication.isRTL ? horizontalScrollView.getChildAt(0).getLeft() : horizontalScrollView.getChildAt(0).getRight(); horizontalScrollView.setScrollX(scrollFromX); ObjectAnimator.ofInt(horizontalScrollView, "scrollX", scrollToX).setDuration(animationDuration) .start();//from ww w . j a v a2 s. c o m } }); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { verticalScrollView.post(new Runnable() { public void run() { int scrollToY = (int) (getToolButtonByToolType(mCurrentToolType).getY() - verticalScrollView.getHeight() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_landscape_button_height) / 2.0f); int scrollFromY = verticalScrollView.getChildAt(0).getBottom(); verticalScrollView.setScrollY(scrollFromY); ObjectAnimator.ofInt(verticalScrollView, "scrollY", scrollToY).setDuration(animationDuration) .start(); } }); } delayedAnimateSelectedTool(animationDuration); }