List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:android.support.transition.ChangeBounds.java
private void captureValues(TransitionValues values) { View view = values.view; if (ViewCompat.isLaidOut(view) || view.getWidth() != 0 || view.getHeight() != 0) { values.values.put(PROPNAME_BOUNDS, new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())); values.values.put(PROPNAME_PARENT, values.view.getParent()); if (mReparent) { values.view.getLocationInWindow(mTempLocation); values.values.put(PROPNAME_WINDOW_X, mTempLocation[0]); values.values.put(PROPNAME_WINDOW_Y, mTempLocation[1]); }/*w w w . j a v a 2 s. co m*/ if (mResizeClip) { values.values.put(PROPNAME_CLIP, ViewCompat.getClipBounds(view)); } } }
From source file:com.ameron32.apps.tapnotes._trial._demo.fragment.expandable.MyExpandableDraggableSwipeableItemAdapter.java
@Override public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) { // check the item is *not* pinned if (mProvider.getGroupItem(groupPosition).isPinnedToSwipeLeft()) { // return false to raise View.OnClickListener#onClick() event return false; }//from w w w . j av a2s. c o m // check is enabled if (!(holder.itemView.isEnabled() && holder.itemView.isClickable())) { return false; } final View containerView = holder.mContainer; final View dragHandleView = holder.mDragHandle; final int offsetX = containerView.getLeft() + (int) (ViewCompat.getTranslationX(containerView) + 0.5f); final int offsetY = containerView.getTop() + (int) (ViewCompat.getTranslationY(containerView) + 0.5f); return !ViewUtil.hitTest(dragHandleView, x - offsetX, y - offsetY); }
From source file:com.contentful.discovery.ui.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;// w w w . ja va 2 s. co m } final int height = getHeight(); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, start interpolating left and right // coordinates between current and next tab if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator rectPaint.setColor(indicatorColor); canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.crazy.toutiaonews.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;// ww w .ja v a2s . c o m } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { // ============ ?? updateSelectedTitle(tabIndex); // =============================== ========= int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure we obey the offset targetScrollX -= mTitleOffset; } scrollTo(targetScrollX, 0); } }
From source file:com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy.java
private void computeRect(final RectF r, View view) { // compute current rectangle according to matrix transformation final float w = view.getWidth(); final float h = view.getHeight(); // use a rectangle at 0,0 to make sure we don't run into issues with scaling r.set(0, 0, w, h);/* w w w . j a v a 2s. co m*/ final Matrix m = mTempMatrix; m.reset(); transformMatrix(m, view); mTempMatrix.mapRect(r); r.offset(view.getLeft(), view.getTop()); // Straighten coords if rotations flipped them if (r.right < r.left) { final float f = r.right; r.right = r.left; r.left = f; } if (r.bottom < r.top) { final float f = r.top; r.top = r.bottom; r.bottom = f; } }
From source file:cn.lanmei.com.dingdong_2.ItemDecoration.StickyHeaderDecoration.java
/** * {@inheritDoc}//from w ww . ja v a 2 s.com */ @Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { // final int count = parent.getChildCount(); LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); RecyclerView.Adapter ra = adapter.getInnerAdapter(); final int count = ra.getItemCount(); for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); // L.MyLog("sticky","onDrawOver:"+adapterPos+"getItemCount"+count); if (adapterPos != RecyclerView.NO_POSITION && (layoutPos == 0 || hasHeader(adapterPos))) { View header = getHeader(parent, adapterPos).itemView; c.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); c.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(c); c.restore(); } } }
From source file:com.ab.view.sliding.AbSlidingTabView2.java
public AbSlidingTabView2(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabScrollView = new AbHorizontalScrollView(context); mTabScrollView.setHorizontalScrollBarEnabled(false); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //mTabLayout// w w w .j a va2 s . c o m mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT)); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabScrollView, layoutParamsFW); //? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { Log.e(TAG, "AbSlidingTabView?context,FragmentActivity"); } FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); mTabScrollView.setSmoothScrollingEnabled(true); mTabScrollView.setOnScrollListener(new AbOnScrollListener() { @Override public void onScrollToRight() { if (D) Log.d(TAG, "onScrollToRight"); } @Override public void onScrollToLeft() { if (D) Log.d(TAG, "onScrollToLeft"); } @Override public void onScrollStoped() { if (D) Log.d(TAG, "onScrollStoped"); } @Override public void onScroll(int arg1) { scrollX = arg1; View view = mTabLayout.getChildAt(mSelectedTabIndex); int toX = view.getLeft() - scrollX; if (D) Log.d(TAG, "X" + startX + "to" + toX); imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } }); }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;//from w w w . ja v a 2 s . c om /* ? */ 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.charon.materialsample.view.ScrollingTabs.java
/** * Select the tab, and move the tab to the middle position * /* w w w. j a va 2 s. c om*/ * @param position Position of the tab. */ protected void selectTab(int position) { if (!isUseSeperator) { for (int i = 0; i < mContainer.getChildCount(); i++) { View tab = mContainer.getChildAt(i); // Make the current tab selected, others unselected. tab.setSelected(i == position); if (mTabAdapter != null) { if (i == position) { mTabAdapter.onTabSelected(position, mContainer); } else { mTabAdapter.onTabUnSelected(i, mContainer); } } } } else { // pos is the position of the tab. for (int i = 0, pos = 0; i < mContainer.getChildCount(); i += 2, pos++) { View tab = mContainer.getChildAt(i); tab.setSelected(pos == position); if (mTabAdapter != null) { if (pos == position) { mTabAdapter.onTabSelected(i, mContainer); } else { mTabAdapter.onTabUnSelected(i, mContainer); } } } } View selectedView = null; if (!isUseSeperator) { selectedView = mContainer.getChildAt(position); } else { selectedView = mContainer.getChildAt(position * 2); } int tabWidth = selectedView.getMeasuredWidth(); int tabLeft = selectedView.getLeft(); // (tabLeft + tabWidth / 2) is the distance from current tab's middle to // the left of the screen int distance = (tabLeft + tabWidth / 2) - mWindowWidth / 2; smoothScrollTo(distance, this.getScrollY()); }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
/** * ?//from w w w. jav a 2 s.com */ private void scrollToChild(int position, int offset) { ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && position < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(position); if (view != null) { // X?? int newScrollX = view.getLeft() + offset; if (position > 0 || offset > 0) { newScrollX -= 240 - getOffset(view.getWidth()) / 2; } // ?X??? if (newScrollX != lastScrollX) { lastScrollX = newScrollX; scrollTo(newScrollX, 0); } } } }