List of usage examples for android.widget ScrollView getScrollY
public final int getScrollY()
From source file:com.czy.reecycleviewheader.ScrollableHelper.java
private static boolean isScrollViewTop(ScrollView scrollView) { if (scrollView != null) { int scrollViewY = scrollView.getScrollY(); return scrollViewY <= 0; }/*from w ww. j a v a 2s . co m*/ return false; }
From source file:com.duy.pascal.ui.editor.view.LineUtils.java
public static int getLastVisibleLine(@NonNull ScrollView scrollView, int childHeight, int lineCount) { if (childHeight == 0) return 0; int line = (scrollView.getScrollY() * lineCount) / childHeight; if (line > lineCount) line = lineCount;/*from ww w . j av a 2 s . c om*/ return line; }
From source file:com.duy.pascal.ui.editor.view.LineUtils.java
public static int getFirstVisibleLine(@NonNull ScrollView scrollView, int childHeight, int lineCount) throws ArithmeticException { if (childHeight == 0) return 0; int line = (scrollView.getScrollY() * lineCount) / childHeight; if (line < 0) line = 0;/*from w ww. j a v a 2 s. c om*/ return line; }
From source file:cn.bingoogolapple.refreshlayout.util.BGARefreshScrollingUtil.java
public static boolean isScrollViewToBottom(ScrollView scrollView) { if (scrollView != null) { int scrollContentHeight = scrollView.getScrollY() + scrollView.getMeasuredHeight() - scrollView.getPaddingTop() - scrollView.getPaddingBottom(); int realContentHeight = scrollView.getChildAt(0).getMeasuredHeight(); if (scrollContentHeight == realContentHeight) { return true; }/*from w ww . j av a 2 s . c o m*/ } return false; }
From source file:com.lanma.customviewproject.utils.ScrollingUtil.java
/** * ScrollView?// w ww .ja v a 2 s. c o m */ public static boolean isScrollViewToBottom(ScrollView scrollView) { if (scrollView != null) { int scrollContentHeight = scrollView.getScrollY() + scrollView.getMeasuredHeight() - scrollView.getPaddingTop() - scrollView.getPaddingBottom(); int realContentHeight = scrollView.getChildAt(0).getMeasuredHeight(); if (scrollContentHeight == realContentHeight) { return true; } } return false; }
From source file:com.my.seams_carv.util.ScrollableViewUtil.java
/** * Return true if the given scrollable view is over scrolling in terms of * the given y momentum./*from w ww. j a v a 2s . co m*/ * <br/> * Usually it is called in the {@code dispatchTouchEvent}, {@code onTouchEvent}, * or the {@code onInterceptTouchEvent}. * * @param view the scrollable view. * @param dy The y momentum. * @return true if the view is over scrolling in the vertical direction. */ public static boolean ifOverScrollingVertically(View view, float dy) { if (view == null || dy == 0) return false; // TODO: Test it. if (view instanceof ScrollView) { final ScrollView scrollView = (ScrollView) view; final View child = scrollView.getChildAt(0); if (scrollView.getHeight() >= child.getHeight()) return true; if (dy > 0) { // Slide the thumb down to scroll up the list. return scrollView.getScrollY() == 0; } else { // Slide the thumb up to scroll down the list. MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams(); return child.getHeight() - scrollView.getScrollY() == scrollView.getHeight() - (params.topMargin + params.bottomMargin); } // } else if (view instanceof WebView) { // WebView webView = (WebView) view; // // // TODO: Complete it. // if (dy > 0) { // // Slide the thumb down to scroll up the list. // return webView.computeHorizontalScrollOffset() == 0.f; // } else { // // Slide the thumb up to scroll down the list. // return false; // } } else if (view instanceof NestedScrollView) { final NestedScrollView scrollView = (NestedScrollView) view; final int scrollRange = scrollView.computeVerticalScrollRange() - scrollView.computeVerticalScrollExtent(); if (scrollRange <= 0) return true; if (dy > 0) { // Slide the thumb down to scroll up the list. return scrollView.computeVerticalScrollOffset() == 0.f; } else { // Slide the thumb up to scroll down the list. return scrollView.computeVerticalScrollOffset() == scrollRange; } } else if (view instanceof ListView) { final ListView listView = (ListView) view; if (listView.getAdapter().getCount() == 0) return true; // TODO: Complete it. if (dy > 0) { // Slide the thumb down to scroll up the list. return listView.getScrollY() == 0; } else { // Slide the thumb up to scroll down the list. return false; } } else if (view instanceof RecyclerView) { final RecyclerView recyclerView = (RecyclerView) view; if (recyclerView.getAdapter().getItemCount() == 0) return true; final int scrollRange = recyclerView.computeVerticalScrollRange() - recyclerView.computeVerticalScrollExtent(); if (dy > 0) { // Slide the thumb down to scroll up the list. return recyclerView.computeVerticalScrollOffset() == 0.f; } else { // Slide the thumb up to scroll down the list. return recyclerView.computeVerticalScrollOffset() == scrollRange; } } // TODO: Support more scrollable view. // Return true for the unsupported view because the dy is non-zero. return true; }
From source file:de.gebatzens.ggvertretungsplan.view.SubstSwipeLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: MotionEvent m = MotionEvent.obtain(event); mPrevX = m.getX();// w w w .j a v a 2 s. co m m.recycle(); break; case MotionEvent.ACTION_MOVE: float xd = Math.abs(event.getX() - mPrevX); if (xd > mTouchSlop) return false; if (GGApp.GG_APP.getFragmentType() == GGApp.FragmentType.PLAN) { int i = ((SubstFragment) ((MainActivity) getContext()).mContent).mViewPager.getCurrentItem(); SubstPagerFragment frag = (SubstPagerFragment) ((FragmentPagerAdapter) ((SubstFragment) ((MainActivity) getContext()).mContent).mViewPager .getAdapter()).getItem(i); ScrollView sv = (ScrollView) frag.getView().findViewWithTag("ggfrag_scrollview"); if (sv != null && sv.getScrollY() != 0) return false; } } return super.onInterceptTouchEvent(event); }
From source file:de.gebatzens.ggvertretungsplan.view.ExamSwipeLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: if (GGApp.GG_APP.getFragmentType() == GGApp.FragmentType.EXAMS) { ScrollView sv = ((ScrollView) ((MainActivity) getContext()).mContent.getView() .findViewWithTag("exam_scroll")); if (sv != null) { int i = -sv.getScrollY(); if (i != 0) return false; } else return super.onInterceptTouchEvent(event); }//w w w .j a v a2 s.com } return super.onInterceptTouchEvent(event); }
From source file:de.gebatzens.ggvertretungsplan.view.MensaSwipeLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: if (GGApp.GG_APP.getFragmentType() == GGApp.FragmentType.MENSA) { ScrollView sv = ((ScrollView) ((MainActivity) getContext()).mContent.getView() .findViewWithTag("mensa_scroll")); if (sv != null) { int i = -sv.getScrollY(); if (i != 0) return false; } else return super.onInterceptTouchEvent(event); }/*from www.j av a 2s . c o m*/ } return super.onInterceptTouchEvent(event); }
From source file:us.koller.todolist.Activities.InfoActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_info); final Toolbar toolbar = (Toolbar) findViewById(R.id.info_activity_toolbar); setSupportActionBar(toolbar);/*from w w w . j a v a 2 s. c om*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(""); } initTheme(toolbar); final ScrollView scrollView = (ScrollView) findViewById(R.id.scroll_view); scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (scrollView.getScrollY() != 0) { elevateToolbar(toolbar); } else { deelevateToolbar(toolbar); } } }); TextView version = (TextView) findViewById(R.id.version); if (helper.lightCoordColor()) { version.setTextColor(ContextCompat.getColor(this, R.color.grey700)); } version.setText(BuildConfig.VERSION_NAME); ImageView icon = (ImageView) findViewById(R.id.icon); Glide.with(this).load("http://todolist.koller.us/todolist_icon_512px").into(icon); //Glide license View license_item_1 = findViewById(R.id.license_item_1); ((TextView) license_item_1.findViewById(R.id.text)).setText(R.string.glide); license_item_1.findViewById(R.id.text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse("https://github.com/bumptech/glide/blob/master/LICENSE"))); } }); license_item_1.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity( new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://github.com/bumptech/glide"))); } }); //MaterialNumberPicker license View license_item_2 = findViewById(R.id.license_item_2); ((TextView) license_item_2.findViewById(R.id.text)).setText(R.string.materialnumberpicker); license_item_2.findViewById(R.id.text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW).setData( Uri.parse("https://github.com/KasualBusiness/MaterialNumberPicker/blob/master/LICENSE"))); } }); license_item_2.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW) .setData(Uri.parse("https://github.com/KasualBusiness/MaterialNumberPicker"))); } }); //Google Play Service Attribution View license_item_3 = findViewById(R.id.license_item_3); ((TextView) license_item_3.findViewById(R.id.text)).setText(R.string.google_play_servcie_attribution); license_item_3.findViewById(R.id.text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { WebView webView = new WebView(InfoActivity.this); webView.loadData( GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(InfoActivity.this), "text/plain", "utf-8"); AlertDialog dialog = new AlertDialog.Builder(InfoActivity.this) .setTitle("Google Play Servcie Attribution").setView(webView).setPositiveButton("Ok", null) .create(); dialog.show(); dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(helper.get(ThemeHelper.FAB_COLOR)); } }); license_item_3.findViewById(R.id.button).setVisibility(View.GONE); //Google Play Service Attribution View license_item_4 = findViewById(R.id.license_item_4); ((TextView) license_item_4.findViewById(R.id.text)).setText("Privacy Policy"); license_item_4.findViewById(R.id.text).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(Intent.ACTION_VIEW).setData( Uri.parse("https://github.com/kollerlukas/TODOList-Android-App/blob/master/PRIVACY.md"))); } }); license_item_4.findViewById(R.id.button).setVisibility(View.GONE); }