Java Code Examples for android.widget.AbsListView#getHeight()
The following examples show how to use
android.widget.AbsListView#getHeight() .
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: ViewCompat.java From SmartSwipe with Apache License 2.0 | 6 votes |
/** * Check if the items in the list can be scrolled in a certain direction. * * @param listView listView * @param direction Negative to check scrolling up, positive to check * scrolling down. * @return true if the list can be scrolled in the specified direction, * false otherwise. */ public static boolean canListViewScrollVertical(AbsListView listView, int direction) { if (Build.VERSION.SDK_INT >= 19) { // Call the framework version directly return listView.canScrollList(direction); } else { // provide backport on earlier versions final int childCount = listView.getChildCount(); if (childCount == 0) { return false; } final int firstPosition = listView.getFirstVisiblePosition(); if (direction > 0) { final int lastBottom = listView.getChildAt(childCount - 1).getBottom(); final int lastPosition = firstPosition + childCount; return lastPosition < listView.getCount() || (lastBottom > listView.getHeight() - listView.getListPaddingBottom()); } else { final int firstTop = listView.getChildAt(0).getTop(); return firstPosition > 0 || firstTop < listView.getListPaddingTop(); } } }
Example 2
Source File: SlideBottomPanel.java From pius1 with GNU Lesser General Public License v3.0 | 6 votes |
/** * Copy From AbsListView (API Level >= 19) * @param absListView AbsListView * @param direction Negative to check scrolling up, positive to check * scrolling down. * @return true if the list can be scrolled in the specified direction, * false otherwise */ private boolean absListViewCanScrollList(AbsListView absListView,int direction) { final int childCount = absListView.getChildCount(); if (childCount == 0) { return false; } final int firstPosition = absListView.getFirstVisiblePosition(); if (direction > 0) {//can scroll down final int lastBottom = absListView.getChildAt(childCount - 1).getBottom(); final int lastPosition = firstPosition + childCount; return lastPosition < absListView.getCount() || lastBottom > absListView.getHeight() - absListView.getPaddingTop(); } else {//can scroll up final int firstTop = absListView.getChildAt(0).getTop(); return firstPosition > 0 || firstTop < absListView.getPaddingTop(); } }
Example 3
Source File: ExpandedScreen.java From Dashchan with Apache License 2.0 | 6 votes |
@Override public void onScroll(AbsListView view, int scrollY, int totalItemCount, boolean first, boolean last) { if (Math.abs(scrollY) > slopShiftSize) { scrollingDown = scrollY > 0; } boolean hide = false; if (scrollingDown) { if (totalItemCount > minItemsCount) { // List can be overscrolled when it shows first item including list top padding // top <= 0 means that list is not overscrolled if (!first || view.getChildAt(0).getTop() <= 0) { if (last) { View lastView = view.getChildAt(view.getChildCount() - 1); if (view.getHeight() - view.getPaddingBottom() - lastView.getBottom() + lastItemLimit < 0) { hide = true; } } else { hide = true; } } } } setShowActionBar(!hide, true); }
Example 4
Source File: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Returns, whether a specific list view is scrolled to the bottom, or not. * * @param scrollView The list view as an instance of the class {@link AbsListView}. The list view may not * be null * @return True, if the given list view is scrolled to the bottom, false otherwise */ private boolean isListViewScrolledToBottom(@NonNull final AbsListView scrollView) { if (scrollView.getCount() > 0 && scrollView.getChildCount() > 0) { if (scrollView.getLastVisiblePosition() == scrollView.getCount() - 1) { View child = scrollView.getChildAt(scrollView.getChildCount() - 1); return child == null || child.getBottom() <= scrollView.getHeight(); } } else { return true; } return false; }
Example 5
Source File: ConversationFragment.java From Pix-Art-Messenger with GNU General Public License v3.0 | 5 votes |
private static boolean scrolledToBottom(AbsListView listView) { final int count = listView.getCount(); if (count == 0) { return true; } else if (listView.getLastVisiblePosition() == count - 1) { final View lastChild = listView.getChildAt(listView.getChildCount() - 1); return lastChild != null && lastChild.getBottom() <= listView.getHeight(); } else { return false; } }
Example 6
Source File: FooterAbsListViewScrollListener.java From AbsListViewHelper with MIT License | 5 votes |
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem + visibleItemCount >= totalItemCount) { final View lastView = view.getChildAt(view.getChildCount() - 1); if (lastView != null) { translationY = footerView.getHeight() - (view.getHeight() - (ViewCompat.getY(lastView) + lastView.getHeight())) + (paddingBottom / 2); ViewCompat.setTranslationY(footerView, translationY); } } else { translationY = footerView.getHeight(); ViewCompat.setTranslationY(footerView, translationY); } }
Example 7
Source File: ConversationFragment.java From Conversations with GNU General Public License v3.0 | 5 votes |
private static boolean scrolledToBottom(AbsListView listView) { final int count = listView.getCount(); if (count == 0) { return true; } else if (listView.getLastVisiblePosition() == count - 1) { final View lastChild = listView.getChildAt(listView.getChildCount() - 1); return lastChild != null && lastChild.getBottom() <= listView.getHeight(); } else { return false; } }
Example 8
Source File: Util.java From dynamiclistview with MIT License | 5 votes |
public static boolean reachedListBottom(AbsListView listView) { boolean flag = true; if (listView.getChildCount() != 0) { int i = listView.getLastVisiblePosition(); int j = listView.getCount(); int k = listView.getHeight(); int l = listView.getChildAt(-1 + listView.getChildCount()).getBottom(); if (i != j - 1 || l > k) { flag = false; } } return flag; }
Example 9
Source File: EdgeScrollListener.java From ProjectX with Apache License 2.0 | 4 votes |
/** * 滚动更改 * * @param view AbsListView * @param firstVisibleItem 第一个可见子项 * @param visibleItemCount 可见子项总数 * @param totalItemCount 子项总数 */ private void onScrollChanged(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (visibleItemCount != 0) { ScrollLocation mNewScrollLocation; final int gridTop = view.getPaddingTop(); final int gridBottom = view.getHeight() - view.getPaddingBottom(); if (totalItemCount == visibleItemCount) { // 头尾均显示,需判断是否可滚动 final int childFristTop = view.getChildAt(0).getTop(); final int childLastBottom = view.getChildAt( visibleItemCount - 1).getBottom(); if (childFristTop >= gridTop && childLastBottom <= gridBottom) { mNewScrollLocation = ScrollLocation.TB; } else if (childFristTop >= gridTop) { mNewScrollLocation = ScrollLocation.TOP; } else if (childLastBottom <= gridBottom) { mNewScrollLocation = ScrollLocation.BOTTOM; } else { mNewScrollLocation = ScrollLocation.CENTER; } } else { // 头尾不完全显示 if (firstVisibleItem == 0) { // 头显示 if (view.getChildAt(0).getTop() >= gridTop) { mNewScrollLocation = ScrollLocation.TOP; } else { mNewScrollLocation = ScrollLocation.CENTER; } } else if (firstVisibleItem + visibleItemCount == totalItemCount) { // 尾显示 if (view.getChildAt(visibleItemCount - 1).getBottom() <= gridBottom) { mNewScrollLocation = ScrollLocation.BOTTOM; } else { mNewScrollLocation = ScrollLocation.CENTER; } } else { // 头尾均不显示 mNewScrollLocation = ScrollLocation.CENTER; } } if (mScrollLocation != mNewScrollLocation) { if (mScrollLocation == ScrollLocation.NULL) { mScrollLocation = mNewScrollLocation; return; } onScrollLocationChanged(mNewScrollLocation, mScrollLocation); mScrollLocation = mNewScrollLocation; } } }