Example usage for android.view View getWidth

List of usage examples for android.view View getWidth

Introduction

In this page you can find the example usage for android.view View getWidth.

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

Usage

From source file:com.battlelancer.seriesguide.ui.MovieDetailsFragment.java

private void populateMovieViews() {
    /**//w  ww  .  j  a  v  a  2  s  .  co m
     * Take title, overview and poster from TMDb as they are localized.
     * Everything else from trakt.
     */
    Movie traktMovie = mMovieDetails.traktMovie();
    com.uwetrottmann.tmdb.entities.Movie tmdbMovie = mMovieDetails.tmdbMovie();

    mMovieTitle.setText(tmdbMovie.title);
    mMovieDescription.setText(tmdbMovie.overview);

    // release date and runtime: "July 17, 2009 | 95 min"
    StringBuilder releaseAndRuntime = new StringBuilder();
    if (traktMovie.released != null && traktMovie.released.getTime() != 0) {
        releaseAndRuntime.append(DateUtils.formatDateTime(getActivity(), traktMovie.released.getTime(),
                DateUtils.FORMAT_SHOW_DATE));
        releaseAndRuntime.append(" | ");
    }
    releaseAndRuntime.append(getString(R.string.runtime_minutes, tmdbMovie.runtime));
    mMovieReleaseDate.setText(releaseAndRuntime.toString());

    // check-in button
    final String title = tmdbMovie.title;
    // fall back to local title for tvtag check-in if we currently don't have the original one
    final String originalTitle = TextUtils.isEmpty(tmdbMovie.original_title) ? title : tmdbMovie.original_title;
    mCheckinButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // display a check-in dialog
            MovieCheckInDialogFragment f = MovieCheckInDialogFragment.newInstance(mTmdbId, title,
                    originalTitle);
            f.show(getFragmentManager(), "checkin-dialog");
            fireTrackerEvent("Check-In");
        }
    });
    CheatSheet.setup(mCheckinButton);

    // watched button (only supported when connected to trakt)
    if (TraktCredentials.get(getActivity()).hasCredentials()) {
        final boolean isWatched = traktMovie.watched != null && traktMovie.watched;
        Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchedButton, 0,
                isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched)
                        : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch),
                0, 0);
        mWatchedButton.setText(isWatched ? R.string.action_unwatched : R.string.action_watched);
        CheatSheet.setup(mWatchedButton, isWatched ? R.string.action_unwatched : R.string.action_watched);
        mWatchedButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // disable button, will be re-enabled on data reload once action completes
                v.setEnabled(false);
                if (isWatched) {
                    MovieTools.unwatchedMovie(getActivity(), mTmdbId);
                    fireTrackerEvent("Unwatched movie");
                } else {
                    MovieTools.watchedMovie(getActivity(), mTmdbId);
                    fireTrackerEvent("Watched movie");
                }
            }
        });
        mWatchedButton.setEnabled(true);
    } else {
        mWatchedButton.setVisibility(View.GONE);
    }

    // collected button
    final boolean isInCollection = traktMovie.inCollection != null && traktMovie.inCollection;
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mCollectedButton, 0,
            isInCollection ? R.drawable.ic_collected
                    : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect),
            0, 0);
    mCollectedButton
            .setText(isInCollection ? R.string.action_collection_remove : R.string.action_collection_add);
    CheatSheet.setup(mCollectedButton,
            isInCollection ? R.string.action_collection_remove : R.string.action_collection_add);
    mCollectedButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable button, will be re-enabled on data reload once action completes
            v.setEnabled(false);
            if (isInCollection) {
                MovieTools.removeFromCollection(getActivity(), mTmdbId);
                fireTrackerEvent("Uncollected movie");
            } else {
                MovieTools.addToCollection(getActivity(), mTmdbId);
                fireTrackerEvent("Collected movie");
            }
        }
    });
    mCollectedButton.setEnabled(true);

    // watchlist button
    final boolean isInWatchlist = traktMovie.inWatchlist != null && traktMovie.inWatchlist;
    Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchlistedButton, 0,
            isInWatchlist ? R.drawable.ic_listed
                    : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableList),
            0, 0);
    mWatchlistedButton.setText(isInWatchlist ? R.string.watchlist_remove : R.string.watchlist_add);
    CheatSheet.setup(mWatchlistedButton, isInWatchlist ? R.string.watchlist_remove : R.string.watchlist_add);
    mWatchlistedButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // disable button, will be re-enabled on data reload once action completes
            v.setEnabled(false);
            if (isInWatchlist) {
                MovieTools.removeFromWatchlist(getActivity(), mTmdbId);
                fireTrackerEvent("Unwatchlist movie");
            } else {
                MovieTools.addToWatchlist(getActivity(), mTmdbId);
                fireTrackerEvent("Watchlist movie");
            }
        }
    });
    mWatchlistedButton.setEnabled(true);

    // show button bar
    mButtonContainer.setVisibility(View.VISIBLE);

    // ratings
    mRatingsTmdbValue.setText(TmdbTools.buildRatingValue(tmdbMovie.vote_average));
    mRatingsTraktUserValue.setText(TraktTools.buildUserRatingString(getActivity(), traktMovie.rating_advanced));
    if (traktMovie.ratings != null) {
        mRatingsTraktVotes.setText(TraktTools.buildRatingVotesString(getActivity(), traktMovie.ratings.votes));
        mRatingsTraktValue.setText(TraktTools.buildRatingPercentageString(traktMovie.ratings.percentage));
    }
    mRatingsContainer.setVisibility(View.VISIBLE);

    // genres
    Utils.setValueOrPlaceholder(mMovieGenres, TmdbTools.buildGenresString(tmdbMovie.genres));

    // trakt comments link
    mCommentsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), TraktShoutsActivity.class);
            i.putExtras(TraktShoutsActivity.createInitBundleMovie(title, mTmdbId));
            ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat
                    .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle());
            fireTrackerEvent("Comments");
        }
    });

    // load poster, cache on external storage
    if (!TextUtils.isEmpty(tmdbMovie.poster_path)) {
        ServiceUtils.getPicasso(getActivity()).load(mImageBaseUrl + tmdbMovie.poster_path)
                .into(mMoviePosterBackground);
    }
}

From source file:com.appunite.list.AbsHorizontalListView.java

/**
 * Allows RemoteViews to scroll relatively to a position.
 *///from   w  ww .java 2  s .com
void smoothScrollByOffset(int position) {
    int index = -1;
    if (position < 0) {
        index = getFirstVisiblePosition();
    } else if (position > 0) {
        index = getLastVisiblePosition();
    }

    if (index > -1) {
        View child = getChildAt(index - getFirstVisiblePosition());
        if (child != null) {
            Rect visibleRect = new Rect();
            if (child.getGlobalVisibleRect(visibleRect)) {
                // the child is partially visible
                int childRectArea = child.getWidth() * child.getHeight();
                int visibleRectArea = visibleRect.width() * visibleRect.height();
                float visibleArea = (visibleRectArea / (float) childRectArea);
                final float visibleThreshold = 0.75f;
                if ((position < 0) && (visibleArea < visibleThreshold)) {
                    // the top index is not perceivably visible so offset
                    // to account for showing that top index as well
                    ++index;
                } else if ((position > 0) && (visibleArea < visibleThreshold)) {
                    // the bottom index is not perceivably visible so offset
                    // to account for showing that bottom index as well
                    --index;
                }
            }
            smoothScrollToPosition(Math.max(0, Math.min(getCount(), index + position)));
        }
    }
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

@Override
protected int computeHorizontalScrollOffset() {
    final int firstPosition = mFirstPosition;
    final int childCount = getChildCount();

    if (firstPosition < 0 || childCount == 0) {
        return 0;
    }/*from   w  ww.j  av  a2  s .c  o  m*/

    final View child = getChildAt(0);
    final int childLeft = child.getLeft();

    int childWidth = child.getWidth();
    if (childWidth > 0) {
        return Math.max(firstPosition * 100 - (childLeft * 100) / childWidth, 0);
    }

    return 0;
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

@Override
protected int computeHorizontalScrollExtent() {
    final int count = getChildCount();
    if (count == 0) {
        return 0;
    }//from   w w w.ja  v a2s.  c o m

    int extent = count * 100;

    View child = getChildAt(0);
    final int childLeft = child.getLeft();

    int childWidth = child.getWidth();
    if (childWidth > 0) {
        extent += (childLeft * 100) / childWidth;
    }

    child = getChildAt(count - 1);
    final int childRight = child.getRight();

    childWidth = child.getWidth();
    if (childWidth > 0) {
        extent -= ((childRight - getWidth()) * 100) / childWidth;
    }

    return extent;
}

From source file:com.freeman.support.v7.widget.RecyclerView.java

private void animateDisappearance(ItemHolderInfo disappearingItem) {
    View disappearingItemView = disappearingItem.holder.itemView;
    addAnimatingView(disappearingItemView);
    int oldLeft = disappearingItem.left;
    int oldTop = disappearingItem.top;
    int newLeft = disappearingItemView.getLeft();
    int newTop = disappearingItemView.getTop();
    if (oldLeft != newLeft || oldTop != newTop) {
        disappearingItem.holder.setIsRecyclable(false);
        disappearingItemView.layout(newLeft, newTop, newLeft + disappearingItemView.getWidth(),
                newTop + disappearingItemView.getHeight());
        if (mIsDebugLoggingEnabled) {
            Log.d(TAG, "DISAPPEARING: " + disappearingItem.holder + " with view " + disappearingItemView);
        }/* w  w  w  .ja v  a  2 s . c  o  m*/
        if (mItemAnimator.animateMove(disappearingItem.holder, oldLeft, oldTop, newLeft, newTop)) {
            postAnimationRunner();
        }
    } else {
        if (mIsDebugLoggingEnabled) {
            Log.d(TAG, "REMOVED: " + disappearingItem.holder + " with view " + disappearingItemView);
        }
        disappearingItem.holder.setIsRecyclable(false);
        if (mItemAnimator.animateRemove(disappearingItem.holder)) {
            postAnimationRunner();
        }
    }
}

From source file:com.android.soma.Launcher.java

/**
 * Launches the intent referred by the clicked shortcut.
 *
 * @param v The view representing the clicked shortcut.
 *///from  w  ww .ja va 2s  .  c  o  m
public void onClick(View v) {
    // Make sure that rogue clicks don't get through while allapps is launching, or after the
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null) {
        return;
    }

    if (!mWorkspace.isFinishedSwitchingState()) {
        return;
    }

    if (v instanceof Workspace) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(true);
        }
        return;
    }

    if (v instanceof CellLayout) {
        if (mWorkspace.isInOverviewMode()) {
            mWorkspace.exitOverviewMode(mWorkspace.indexOfChild(v), true);
        }
    }

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        // Open shortcut
        final ShortcutInfo shortcut = (ShortcutInfo) tag;
        final Intent intent = shortcut.intent;

        // Check for special shortcuts
        if (intent.getComponent() != null) {
            final String shortcutClass = intent.getComponent().getClassName();

            if (shortcutClass.equals(WidgetAdder.class.getName())) {
                showAllApps(true, AppsCustomizePagedView.ContentType.Widgets, true);
                return;
            } else if (shortcutClass.equals(MemoryDumpActivity.class.getName())) {
                MemoryDumpActivity.startDump(this);
                return;
            } else if (shortcutClass.equals(ToggleWeightWatcher.class.getName())) {
                toggleShowWeightWatcher();
                return;
            }
        }

        // Start activities
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
        intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()));

        boolean success = startActivitySafely(v, intent, tag);

        mStats.recordLaunch(intent, shortcut);

        if (success && v instanceof BubbleTextView) {
            mWaitingForResume = (BubbleTextView) v;
            mWaitingForResume.setStayPressed(true);
        }
    } else if (tag instanceof FolderInfo) {
        if (v instanceof FolderIcon) {
            FolderIcon fi = (FolderIcon) v;
            handleFolderClick(fi);
        }
    } else if (v == mAllAppsButton) {
        if (isAllAppsVisible()) {
            showWorkspace(true);
        } else {
            onClickAllAppsButton(v);
        }
    }
}

From source file:com.artifex.mupdflib.TwoWayView.java

private int getChildSize(View child) {
    return (mIsVertical ? child.getHeight() : child.getWidth());
}

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

/**
 * Animations to update the views on screen to their new positions.  For new views that aren't
 * currently on screen, animate them in using the specified animationInMode.
 *//*from w  w  w . j  a  v a2  s.  c o m*/
private List<Animator> addUpdateViewPositionsAnimators(List<Animator> animators, boolean cascadeAnimation,
        AnimationIn animationInMode, int startDelay) {
    final int childCount = getChildCount();
    if (childCount == 0) {
        return null;
    }

    if (animators == null) {
        animators = new ArrayList<Animator>();
    }

    int viewsAnimated = 0;
    for (int i = 0; i < childCount; i++) {
        final View childToAnimate = getChildAt(i);

        if (mViewsToAnimateOut.contains(childToAnimate)) {
            // If the stale views are still animating, then they are still laid out, so
            // getChildCount() would've accounted for them.  Since they have their own set
            // of animations to play, we'll skip over them in this loop.
            continue;
        }

        // Use progressive animation delay to create the staggered effect of animating
        // views.  This is done by having each view delay their animation by
        // ANIMATION_DELAY_IN_MS after the animation of the previous view.
        int animationDelay = startDelay + (cascadeAnimation ? viewsAnimated * ANIMATION_DELAY_IN_MS : 0);

        // Figure out whether a view with this item ID existed before
        final LayoutParams lp = (LayoutParams) childToAnimate.getLayoutParams();

        final ViewRectPair viewRectPair = mChildRectsForAnimation.get(lp.id);

        final int xTranslation;
        final int yTranslation;

        // If there is a valid {@link Rect} for the view with this newId, then
        // setup an animation.
        if (viewRectPair != null && viewRectPair.rect != null) {
            // In the special case where the items are explicitly fading, we don't want to do
            // any of the translations.
            if (animationInMode == AnimationIn.FADE) {
                SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                        1.0f /* end alpha */, animationDelay);
                continue;
            }

            final Rect oldRect = viewRectPair.rect;
            // Since the view already exists, translate it to its new position.
            // Reset the child back to its previous position given by oldRect if the child
            // has not already been translated.  If the child has been translated, use the
            // current translated values, as this child may be in the middle of a previous
            // animation, so we don't want to simply force it to new location.

            xTranslation = oldRect.left - childToAnimate.getLeft();
            yTranslation = oldRect.top - childToAnimate.getTop();
            final float rotation = childToAnimate.getRotation();

            // First set the translation X and Y. The current translation might be out of date.
            childToAnimate.setTranslationX(xTranslation);
            childToAnimate.setTranslationY(yTranslation);

            if (xTranslation == 0 && yTranslation == 0 && rotation == 0) {
                // Bail early if this view doesn't need to be translated.
                continue;
            }

            SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation,
                    yTranslation, rotation, animationDelay);
        } else {
            // If this view was not present before the data updated, rather than just flashing
            // the view into its designated position, fly it up from the bottom.
            xTranslation = 0;
            yTranslation = (animationInMode == AnimationIn.FLY_IN_NEW_VIEWS) ? getHeight() : 0;

            // Since this is a new view coming in, add additional delays so that these IN
            // animations start after all the OUT animations have been played.
            animationDelay += SgvAnimationHelper.getDefaultAnimationDuration();

            childToAnimate.setTranslationX(xTranslation);
            childToAnimate.setTranslationY(yTranslation);

            switch (animationInMode) {
            case FLY_IN_NEW_VIEWS:
                SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation,
                        yTranslation, SgvAnimationHelper.ANIMATION_ROTATION_DEGREES, animationDelay);
                break;

            case SLIDE_IN_NEW_VIEWS:
                // Bias towards sliding right, but depending on the column that this view
                // is laid out in, slide towards the nearest side edge.
                int startTranslation = (int) (childToAnimate.getWidth() * 1.5);
                if (lp.column < (mColCount / 2)) {
                    startTranslation = -startTranslation;
                }

                SgvAnimationHelper.addSlideInFromRightAnimators(animators, childToAnimate, startTranslation,
                        animationDelay);
                break;

            case EXPAND_NEW_VIEWS:
            case EXPAND_NEW_VIEWS_NO_CASCADE:
                if (i == 0) {
                    // Initially set the alpha of this view to be invisible, then fade in.
                    childToAnimate.setAlpha(0);

                    // Create animators that translate the view back to translation = 0
                    // which would be its new layout position
                    final int offset = -1 * childToAnimate.getHeight();
                    SgvAnimationHelper.addXYTranslationAnimators(animators, childToAnimate,
                            0 /* xTranslation */, offset, animationDelay);

                    SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                            1.0f /* end alpha */, animationDelay);
                } else {
                    SgvAnimationHelper.addExpandInAnimators(animators, childToAnimate, animationDelay);
                }
                break;
            case FADE:
                SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                        1.0f /* end alpha */, animationDelay);
                break;

            default:
                continue;
            }
        }

        viewsAnimated++;
    }

    return animators;
}

From source file:com.deepak.myclock.widget.sgv.StaggeredGridView.java

/**
 * Animations to update the views on screen to their new positions.  For new views that aren't
 * currently on screen, animate them in using the specified animationInMode.
 *//*from  w w w.ja v a 2 s.c  om*/
private List<Animator> addUpdateViewPositionsAnimators(List<Animator> animators, boolean cascadeAnimation,
        SgvAnimationHelper.AnimationIn animationInMode, int startDelay) {
    final int childCount = getChildCount();
    if (childCount == 0) {
        return null;
    }

    if (animators == null) {
        animators = new ArrayList<Animator>();
    }

    int viewsAnimated = 0;
    for (int i = 0; i < childCount; i++) {
        final View childToAnimate = getChildAt(i);

        if (mViewsToAnimateOut.contains(childToAnimate)) {
            // If the stale views are still animating, then they are still laid out, so
            // getChildCount() would've accounted for them.  Since they have their own set
            // of animations to play, we'll skip over them in this loop.
            continue;
        }

        // Use progressive animation delay to create the staggered effect of animating
        // views.  This is done by having each view delay their animation by
        // ANIMATION_DELAY_IN_MS after the animation of the previous view.
        int animationDelay = startDelay + (cascadeAnimation ? viewsAnimated * ANIMATION_DELAY_IN_MS : 0);

        // Figure out whether a view with this item ID existed before
        final LayoutParams lp = (LayoutParams) childToAnimate.getLayoutParams();

        final ViewRectPair viewRectPair = mChildRectsForAnimation.get(lp.id);

        final int xTranslation;
        final int yTranslation;

        // If there is a valid {@link Rect} for the view with this newId, then
        // setup an animation.
        if (viewRectPair != null && viewRectPair.rect != null) {
            // In the special case where the items are explicitly fading, we don't want to do
            // any of the translations.
            if (animationInMode == SgvAnimationHelper.AnimationIn.FADE) {
                SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                        1.0f /* end alpha */, animationDelay);
                continue;
            }

            final Rect oldRect = viewRectPair.rect;
            // Since the view already exists, translate it to its new position.
            // Reset the child back to its previous position given by oldRect if the child
            // has not already been translated.  If the child has been translated, use the
            // current translated values, as this child may be in the middle of a previous
            // animation, so we don't want to simply force it to new location.

            xTranslation = oldRect.left - childToAnimate.getLeft();
            yTranslation = oldRect.top - childToAnimate.getTop();
            final float rotation = childToAnimate.getRotation();

            // First set the translation X and Y. The current translation might be out of date.
            childToAnimate.setTranslationX(xTranslation);
            childToAnimate.setTranslationY(yTranslation);

            if (xTranslation == 0 && yTranslation == 0 && rotation == 0) {
                // Bail early if this view doesn't need to be translated.
                continue;
            }

            SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation,
                    yTranslation, rotation, animationDelay);
        } else {
            // If this view was not present before the data updated, rather than just flashing
            // the view into its designated position, fly it up from the bottom.
            xTranslation = 0;
            yTranslation = (animationInMode == SgvAnimationHelper.AnimationIn.FLY_IN_NEW_VIEWS) ? getHeight()
                    : 0;

            // Since this is a new view coming in, add additional delays so that these IN
            // animations start after all the OUT animations have been played.
            animationDelay += SgvAnimationHelper.getDefaultAnimationDuration();

            childToAnimate.setTranslationX(xTranslation);
            childToAnimate.setTranslationY(yTranslation);

            switch (animationInMode) {
            case FLY_IN_NEW_VIEWS:
                SgvAnimationHelper.addTranslationRotationAnimators(animators, childToAnimate, xTranslation,
                        yTranslation, SgvAnimationHelper.ANIMATION_ROTATION_DEGREES, animationDelay);
                break;

            case SLIDE_IN_NEW_VIEWS:
                // Bias towards sliding right, but depending on the column that this view
                // is laid out in, slide towards the nearest side edge.
                int startTranslation = (int) (childToAnimate.getWidth() * 1.5);
                if (lp.column < (mColCount / 2)) {
                    startTranslation = -startTranslation;
                }

                SgvAnimationHelper.addSlideInFromRightAnimators(animators, childToAnimate, startTranslation,
                        animationDelay);
                break;

            case EXPAND_NEW_VIEWS:
            case EXPAND_NEW_VIEWS_NO_CASCADE:
                if (i == 0) {
                    // Initially set the alpha of this view to be invisible, then fade in.
                    childToAnimate.setAlpha(0);

                    // Create animators that translate the view back to translation = 0
                    // which would be its new layout position
                    final int offset = -1 * childToAnimate.getHeight();
                    SgvAnimationHelper.addXYTranslationAnimators(animators, childToAnimate,
                            0 /* xTranslation */, offset, animationDelay);

                    SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                            1.0f /* end alpha */, animationDelay);
                } else {
                    SgvAnimationHelper.addExpandInAnimators(animators, childToAnimate, animationDelay);
                }
                break;
            case FADE:
                SgvAnimationHelper.addFadeAnimators(animators, childToAnimate, 0 /* start alpha */,
                        1.0f /* end alpha */, animationDelay);
                break;

            default:
                continue;
            }
        }

        viewsAnimated++;
    }

    return animators;
}

From source file:android.support.v7.widget.RecyclerViewEx.java

@Override
public void requestChildFocus(View child, View focused) {
    if (!mLayout.onRequestChildFocus(this, mState, child, focused) && focused != null) {
        mTempRect.set(0, 0, focused.getWidth(), focused.getHeight());
        offsetDescendantRectToMyCoords(focused, mTempRect);
        offsetRectIntoDescendantCoords(child, mTempRect);
        requestChildRectangleOnScreen(child, mTempRect, !mFirstLayoutComplete);
    }/*from  w w  w  . j  a v a 2  s.  c om*/
    super.requestChildFocus(child, focused);
}