public override int getBaseline() { android.view.View child = null; if (getChildCount() > 0) { child = getChildAt(0); } else { if (mAdapter != null && mAdapter.getCount() > 0) { child = makeAndAddView(0); mRecycler.put(0, child); removeAllViewsInLayout(); } } if (child != null) { int childBaseline = child.getBaseline(); return(childBaseline >= 0 ? child.getTop() + childBaseline : -1); } else { return(-1); } }
private int getThumbPositionForListPosition(int firstVisibleItem, int visibleItemCount , int totalItemCount) { if (mSectionIndexer == null || mListAdapter == null) { getSectionsFromIndexer(); } if (mSectionIndexer == null || !mMatchDragPosition) { return(((mList.getHeight() - mThumbH) * firstVisibleItem) / (totalItemCount - visibleItemCount )); } firstVisibleItem -= mListOffset; if (firstVisibleItem < 0) { return(0); } totalItemCount -= mListOffset; int trackHeight = mList.getHeight() - mThumbH; int section = mSectionIndexer.getSectionForPosition(firstVisibleItem); int sectionPos = mSectionIndexer.getPositionForSection(section); int nextSectionPos = mSectionIndexer.getPositionForSection(section + 1); int sectionCount = mSections.Length; int positionsInSection = nextSectionPos - sectionPos; android.view.View child = mList.getChildAt(0); float incrementalPos = child == null ? 0 : firstVisibleItem + (float)(mList.getPaddingTop () - child.getTop()) / child.getHeight(); float posWithinSection = (incrementalPos - sectionPos) / positionsInSection; int result = (int)((section + posWithinSection) / sectionCount * trackHeight); // Fake out the scrollbar for the last item. Since the section indexer won't // ever actually move the list in this end space, make scrolling across the last item // account for whatever space is remaining. if (firstVisibleItem > 0 && firstVisibleItem + visibleItemCount == totalItemCount) { android.view.View lastChild = mList.getChildAt(visibleItemCount - 1); float lastItemVisible = (float)(mList.getHeight() - mList.getPaddingBottom() - lastChild .getTop()) / lastChild.getHeight(); result += (int)((trackHeight - result) * lastItemVisible); } return(result); }
protected internal override void onLayout(bool changed, int l, int t, int r, int b) { base.onLayout(changed, l, t, r, b); bool hasTabs = mTabContainer != null && mTabContainer.getVisibility() != GONE; if (mTabContainer != null && mTabContainer.getVisibility() != GONE) { int containerHeight = getMeasuredHeight(); int tabHeight = mTabContainer.getMeasuredHeight(); if ((mActionBarView.getDisplayOptions() & android.app.ActionBar.DISPLAY_SHOW_HOME ) == 0) { // Not showing home, put tabs on top. int count = getChildCount(); { for (int i = 0; i < count; i++) { android.view.View child = getChildAt(i); if (child == mTabContainer) { continue; } if (!mActionBarView.isCollapsed()) { child.offsetTopAndBottom(tabHeight); } } } mTabContainer.layout(l, 0, r, tabHeight); } else { mTabContainer.layout(l, containerHeight - tabHeight, r, containerHeight); } } bool needsInvalidate = false; if (mIsSplit) { if (mSplitBackground != null) { mSplitBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight()); needsInvalidate = true; } } else { if (mBackground != null) { mBackground.setBounds(mActionBarView.getLeft(), mActionBarView.getTop(), mActionBarView .getRight(), mActionBarView.getBottom()); needsInvalidate = true; } if ((mIsStacked = hasTabs && mStackedBackground != null)) { mStackedBackground.setBounds(mTabContainer.getLeft(), mTabContainer.getTop(), mTabContainer .getRight(), mTabContainer.getBottom()); needsInvalidate = true; } } if (needsInvalidate) { invalidate(); } }