List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.lgh.tool.myview.PagerSlidingTabStrip.java
/** * ViewPager/*from w w w . j ava2 s . c o m*/ * @param viewPager ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } } @Override public void onPageScrolled(int nextPagePosition, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (nextPagePosition < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(nextPagePosition); if (view != null) { currentPosition = nextPagePosition; currentPositionOffset = positionOffset; scrollToChild(nextPagePosition, (int) (positionOffset * (view.getWidth() + getLeftMargin(view) + getRightMargin(view)))); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(nextPagePosition, positionOffset, positionOffsetPixels); } } @Override public void onPageScrollStateChanged(int arg0) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(arg0); } } }); requestLayout(); }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;// w w w . j a v a 2s . c o m /* ? */ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab != null) { float slidingBlockLeft = currentTab.getLeft(); float slidingBlockRight = currentTab.getRight(); if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) { View nextTab = tabsLayout.getChildAt(currentPosition + 1); if (nextTab != null) { final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); slidingBlockLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * slidingBlockLeft); slidingBlockRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * slidingBlockRight); } } slidingBlockDrawable.setBounds((int) slidingBlockLeft, 0, (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); } } }
From source file:com.ststudy.client.android.ui.pagerslidingtabstrip.PagerSlidingTabStrip.java
/** * ViewPager/*from w w w . ja va 2 s.c om*/ * * @param viewPager ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.addOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } } @Override public void onPageScrolled(int nextPagePosition, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (nextPagePosition < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(nextPagePosition); if (view != null) { currentPosition = nextPagePosition; currentPositionOffset = positionOffset; scrollToChild(nextPagePosition, (int) (positionOffset * (view.getWidth() + getLeftMargin(view) + getRightMargin(view)))); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(nextPagePosition, positionOffset, positionOffsetPixels); } } @Override public void onPageScrollStateChanged(int arg0) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(arg0); } } }); requestLayout(); }
From source file:com.cp.mylibrary.custom.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;//from ww w. j a va 2s . co m /* ? */ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab != null) { float slidingBlockLeft = currentTab.getLeft(); float slidingBlockRight = currentTab.getRight(); if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) { View nextTab = tabsLayout.getChildAt(currentPosition + 1); if (nextTab != null) { final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); slidingBlockLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * slidingBlockLeft); slidingBlockRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * slidingBlockRight); } } slidingBlockDrawable.setBounds((int) slidingBlockLeft, 0, (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); } } }
From source file:com.xnf.henghenghui.ui.view.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // if (disableViewPager) // return; /* ? *//*ww w. j a va2s .c o m*/ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab != null) { float slidingBlockLeft = currentTab.getLeft(); float slidingBlockRight = currentTab.getRight(); if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) { View nextTab = tabsLayout.getChildAt(currentPosition + 1); if (nextTab != null) { final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); slidingBlockLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * slidingBlockLeft); slidingBlockRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * slidingBlockRight); } } slidingBlockDrawable.setBounds((int) slidingBlockLeft, 0, (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); } } }
From source file:com.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;// w w w . j av a 2s. c o m /* ? */ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab != null) { float slidingBlockLeft = getTabTextLeft((ViewGroup) currentTab); float slidingBlockRight = getTabTextRight((ViewGroup) currentTab); if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) { View nextTab = tabsLayout.getChildAt(currentPosition + 1); if (nextTab != null) { final float nextTabLeft = getTabTextLeft((ViewGroup) nextTab); final float nextTabRight = getTabTextRight((ViewGroup) nextTab); slidingBlockLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * slidingBlockLeft); slidingBlockRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * slidingBlockRight); } } slidingBlockDrawable.setBounds((int) slidingBlockLeft, getHeight() - slidingBlockHeight, (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); } } }
From source file:com.glanznig.beepme.view.ExportActivity.java
private void enableDisableView(View view, boolean enabled) { view.setEnabled(enabled);//from w w w. j a v a 2 s. c o m if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0; i < group.getChildCount(); i++) { enableDisableView(group.getChildAt(i), enabled); } } }
From source file:com.m1racle.yuedong.ui.widget.PagerSlidingTabStrip.java
/** * ViewPager// w ww.j a va 2 s . c o m * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.addOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } if (listener != null) listener.onChanged(position); } @Override public void onPageScrolled(int nextPagePosition, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (nextPagePosition < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(nextPagePosition); if (view != null) { currentPosition = nextPagePosition; currentPositionOffset = positionOffset; scrollToChild(nextPagePosition, (int) (positionOffset * view.getWidth())); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(nextPagePosition, positionOffset, positionOffsetPixels); } } @Override public void onPageScrollStateChanged(int arg0) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(arg0); } } }); requestLayout(); }
From source file:com.app.jdy.activity.GoldActivity.java
/** * ?/* w w w .j av a2 s . c o m*/ * * @param viewGroup * @param flag * @return */ public View findViewByType(ViewGroup viewGroup, int flag) { for (int i = 0; i < viewGroup.getChildCount(); i++) { View view = viewGroup.getChildAt(i); if (view instanceof TextView && flag == 1) { return view; } else if (view instanceof ImageView && flag == 2) { return view; } else if (view instanceof ViewGroup) { view = findViewByType((ViewGroup) view, flag); if (view != null) { return view; } } } return null; }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
/** * ViewPager//from w w w . j av a 2 s. co m * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } if (listener != null) listener.onChanged(position); } @Override public void onPageScrolled(int nextPagePosition, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (nextPagePosition < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(nextPagePosition); if (view != null) { currentPosition = nextPagePosition; currentPositionOffset = positionOffset; scrollToChild(nextPagePosition, (int) (positionOffset * view.getWidth())); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(nextPagePosition, positionOffset, positionOffsetPixels); } } @Override public void onPageScrollStateChanged(int arg0) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(arg0); } } }); requestLayout(); }