本文整理汇总了Java中android.widget.AbsListView.getChildAt方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.getChildAt方法的具体用法?Java AbsListView.getChildAt怎么用?Java AbsListView.getChildAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.getChildAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAbsListViewToBottom
import android.widget.AbsListView; //导入方法依赖的package包/类
public static boolean isAbsListViewToBottom(AbsListView absListView) {
if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(absListView);
if (stickyNavLayout != null) {
// 处理BGAStickyNavLayout中lastChild.getBottom() <= absListView.getMeasuredHeight()失效问题
// 0表示x,1表示y
int[] location = new int[2];
lastChild.getLocationOnScreen(location);
int lastChildBottomOnScreen = location[1] + lastChild.getMeasuredHeight();
stickyNavLayout.getLocationOnScreen(location);
int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
return lastChildBottomOnScreen + absListView.getPaddingBottom() <= stickyNavLayoutBottomOnScreen;
} else {
return lastChild.getBottom() <= absListView.getMeasuredHeight();
}
}
return false;
}
示例2: canChildScrollDown
import android.widget.AbsListView; //导入方法依赖的package包/类
public boolean canChildScrollDown() {
if (android.os.Build.VERSION.SDK_INT < 14) {
if (mTarget instanceof AbsListView) {
final AbsListView absListView = (AbsListView) mTarget;
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
if (lastChild != null) {
return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
&& lastChild.getBottom() > absListView.getPaddingBottom();
} else {
return false;
}
} else {
return mTarget.getHeight() - mTarget.getScrollY() > 0;
}
} else {
return ViewCompat.canScrollVertically(mTarget, 1);
}
}
示例3: onScrollToTopOrBottom
import android.widget.AbsListView; //导入方法依赖的package包/类
private void onScrollToTopOrBottom(AbsListView view) {
View childAt = view.getChildAt(0);
if (childAt == null) {
return;
}
//滑动到顶部
if (view.getFirstVisiblePosition() == 0 &&
childAt.getTop() >= 0) {
//It is scrolled all the way up here
if (mScrollChangeListener != null) {
mScrollChangeListener.onScrollToTop();
}
}
//滑动到底部
if (view.getLastVisiblePosition() == view.getAdapter().getCount() - 1 &&
view.getChildAt(
view.getChildCount() - 1).getBottom() <= view.getHeight()) {
if (mScrollChangeListener != null) {
mScrollChangeListener.onScrollToBottom();
}
}
}
示例4: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
final View topChild = view.getChildAt(0);
int firstViewTop = 0;
if (topChild != null) {
firstViewTop = topChild.getTop();
}
boolean goingDown;
boolean changed = true;
if (mPrevPosition == firstVisibleItem) {
final int topDelta = mPrevTop - firstViewTop;
goingDown = firstViewTop < mPrevTop;
changed = Math.abs(topDelta) > DIRECTION_CHANGE_THRESHOLD;
} else {
goingDown = firstVisibleItem > mPrevPosition;
}
if (changed && mUpdated) {
mFloatingActionButton.hide(goingDown);
}
mPrevPosition = firstVisibleItem;
mPrevTop = firstViewTop;
mUpdated = true;
}
示例5: updateListViewScrollState
import android.widget.AbsListView; //导入方法依赖的package包/类
private void updateListViewScrollState(AbsListView listView) {
if (listView.getChildCount() == 0) {
setDraggable(true);
} else {
if (listView.getFirstVisiblePosition() == 0) {
View firstChild = listView.getChildAt(0);
if (firstChild.getTop() == listView.getPaddingTop()) {
setDraggable(true);
return;
}
}
setDraggable(false);
}
}
示例6: isAbsListViewToBottom
import android.widget.AbsListView; //导入方法依赖的package包/类
public static boolean isAbsListViewToBottom(AbsListView absListView) {
if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
return lastChild.getBottom() <= absListView.getMeasuredHeight();
}
return false;
}
示例7: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
SimpleMonthView child = (SimpleMonthView) view.getChildAt(0);
if (child == null) {
return;
}
// Figure out where we are
long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();
mPreviousScrollPosition = currScroll;
mPreviousScrollState = mCurrentScrollState;
}
示例8: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* Updates the title and selected month if the view has moved to a new
* month.
*/
@Override
public void onScroll(
AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
MonthView child = (MonthView) view.getChildAt(0);
if (child == null) {
return;
}
// Figure out where we are
long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();
mPreviousScrollPosition = currScroll;
mPreviousScrollState = mCurrentScrollState;
}
示例9: isScrollTop
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* ContentView是否滚动到顶部
*/
private boolean isScrollTop() {
if (mContentView instanceof RecyclerView)
return ((RecyclerView) mContentView).computeVerticalScrollOffset() == 0;
if (mContentView instanceof AbsListView) {
boolean result = false;
AbsListView listView = (AbsListView) mContentView;
if (listView.getFirstVisiblePosition() == 0) {
final View topChildView = listView.getChildAt(0);
result = topChildView.getTop() == 0;
}
return result;
}
return mContentView.getScrollY() == 0;
}
示例10: getScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* 获取View的滑动距离
*
* @param view
* @return
*/
private int getScroll(AbsListView view) {
View c = view.getChildAt(0); //this is the first visible row
if (c == null) {
return 0;
}
int scrollY = -c.getTop();
listViewItemHeights.put(view.getFirstVisiblePosition(), c.getHeight());
for (int i = 0; i < view.getFirstVisiblePosition(); ++i) {
if (listViewItemHeights.get(i) != null) // (this is a sanity check)
scrollY += listViewItemHeights.get(i); //add all heights of the views that are gone
}
return scrollY;
}
示例11: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int endFadeItem) {
if (mTransparentEnabled && firstVisibleItem <= endFadeItem) {
View v = view.getChildAt(0);
// Top of visible window, originally 0, turn to negative when scroll to lower position
int top = (v == null) ? 0 : v.getTop();
// distance from top of current window to ending position of fade
int delta = top + mEndFadePosition - 4;
mAlpha = interpolate(delta);
setTitleBarTranslate(mAlpha);
}
}
示例12: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
SimpleMonthView child = (SimpleMonthView) view.getChildAt(0);
if (child == null) {
return;
}
// Figure out where we are
long currScroll = view.getFirstVisiblePosition() * child.getHeight()
- child.getBottom();
mPreviousScrollPosition = currScroll;
mPreviousScrollState = mCurrentScrollState;
}
示例13: isAbsListViewToBottom
import android.widget.AbsListView; //导入方法依赖的package包/类
public static boolean isAbsListViewToBottom(AbsListView absListView) {
if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
return lastChild.getBottom() >= absListView.getMeasuredHeight();
//return true;
}
return false;
}
示例14: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View firstChild = view.getChildAt(0);
if (firstChild == null) {
return;
}
int top = firstChild.getTop();
int height = firstChild.getHeight();
int delta;
int skipped = 0;
if (lastFirstVisibleItem == firstVisibleItem) {
delta = lastTop - top;
} else if (firstVisibleItem > lastFirstVisibleItem) {
skipped = firstVisibleItem - lastFirstVisibleItem - 1;
delta = skipped * height + lastHeight + lastTop - top;
} else {
skipped = lastFirstVisibleItem - firstVisibleItem - 1;
delta = skipped * -height + lastTop - (height + top);
}
boolean exact = skipped > 0;
scrollPosition += -delta;
if (listener != null) {
listener.onScrollUpDownChanged(-delta, scrollPosition, exact);
}
lastFirstVisibleItem = firstVisibleItem;
lastTop = top;
lastHeight = firstChild.getHeight();
}
示例15: onScroll
import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View childAt = view.getChildAt(0);
if (childAt == null)
return;
int scrollY = firstVisibleItem * childAt.getHeight() - childAt.getTop();
if (scrollY <= (mScreenHeight / 3f)) {
float alpha = 1f - (scrollY / (mScreenHeight / 3f));
Log.e("CSDN_LQR", "scrollY = " + scrollY);
Log.e("CSDN_LQR", "alpha = " + alpha);
mToolbar.setAlpha(alpha);
}
}