Example usage for android.view View getPaddingTop

List of usage examples for android.view View getPaddingTop

Introduction

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

Prototype

public int getPaddingTop() 

Source Link

Document

Returns the top padding of this view.

Usage

From source file:org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView.java

/**
 * Snaps the scroll point of the RecyclerView to prevent the user from scrolling to midway
 * through a transition and to allow peeking card behaviour.
 *///w  ww  .  j av a  2s. c  om
public void snapScroll(View fakeBox, int parentScrollY, int parentHeight) {
    // Snap scroll to prevent resting in the middle of the omnibox transition.
    final int searchBoxTransitionLength = getResources()
            .getDimensionPixelSize(R.dimen.ntp_search_box_transition_length);
    int fakeBoxUpperBound = fakeBox.getTop() + fakeBox.getPaddingTop();
    if (scrollOutOfRegion(fakeBoxUpperBound - searchBoxTransitionLength, fakeBoxUpperBound)) {
        // The snap scrolling regions should never overlap.
        return;
    }

    // Snap scroll to prevent resting in the middle of the peeking card transition
    // and to allow the peeking card to peek a bit before snapping back.
    CardViewHolder peekingCardViewHolder = findFirstCard();
    if (peekingCardViewHolder != null && isFirstItemVisible()) {
        if (!mHasSpaceForPeekingCard)
            return;

        ViewHolder firstHeaderViewHolder = findFirstHeader();
        // It is possible to have a card but no header, for example the sign in promo.
        // That one does not peek.
        if (firstHeaderViewHolder == null)
            return;

        View peekingCardView = peekingCardViewHolder.itemView;
        View headerView = firstHeaderViewHolder.itemView;
        final int peekingHeight = getResources()
                .getDimensionPixelSize(R.dimen.snippets_padding_and_peeking_card_height);

        // |A + B - C| gives the offset of the peeking card relative to the Recycler View,
        // so scrolling to this point would put the peeking card at the top of the
        // screen. Remove the |headerView| height which gets dynamically increased with
        // scrolling.
        // |A + B - C - D| will scroll us so that the peeking card is just off the bottom
        // of the screen.
        // Finally, we get |A + B - C - D + E| because the transition starts from the
        // peeking card's resting point, which is |E| from the bottom of the screen.
        int start = peekingCardView.getTop() // A.
                + parentScrollY // B.
                - headerView.getHeight() // C.
                - parentHeight // D.
                + peekingHeight; // E.

        // The height of the region in which the the peeking card will snap.
        int snapScrollHeight = peekingHeight + headerView.getHeight();

        scrollOutOfRegion(start, start + snapScrollHeight, start + snapScrollHeight);
    }
}

From source file:com.ashish.routofy.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }/*  w  ww . j  a  v a 2  s  .  c  o  m*/
            }
        }
    }
}

From source file:com.ghkjgod.lightnovel.component.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/*from   ww  w  .j  a  v  a  2 s  .  c o  m*/
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:net.osmand.plus.views.controls.PagerSlidingTabStrip.java

private void updateTabStyles() {
    tabsContainer.setBackgroundResource(tabBackgroundResId);
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            tab_title.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }/*from   w w w  . j a va2 s  .  c o m*/
            }
        }
    }
}

From source file:android.support.design.widget.BaseTransientBottomBar.java

/**
 * Constructor for the transient bottom bar.
 *
 * @param parent The parent for this transient bottom bar.
 * @param content The content view for this transient bottom bar.
 * @param contentViewCallback The content view callback for this transient bottom bar.
 *//*from   w w w  . ja v a2s.  c om*/
protected BaseTransientBottomBar(@NonNull ViewGroup parent, @NonNull View content,
        @NonNull ContentViewCallback contentViewCallback) {
    if (parent == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
    }
    if (content == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null content");
    }
    if (contentViewCallback == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null callback");
    }

    mTargetParent = parent;
    mContentViewCallback = contentViewCallback;
    mContext = parent.getContext();

    ThemeUtils.checkAppCompatTheme(mContext);

    LayoutInflater inflater = LayoutInflater.from(mContext);
    // Note that for backwards compatibility reasons we inflate a layout that is defined
    // in the extending Snackbar class. This is to prevent breakage of apps that have custom
    // coordinator layout behaviors that depend on that layout.
    mView = (SnackbarBaseLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false);
    mView.addView(content);

    ViewCompat.setAccessibilityLiveRegion(mView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(mView, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(mView, true);
    ViewCompat.setOnApplyWindowInsetsListener(mView, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            // Copy over the bottom inset as padding so that we're displayed
            // above the navigation bar
            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
                    insets.getSystemWindowInsetBottom());
            return insets;
        }
    });

    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}

From source file:com.csform.android.uiapptemplate.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }//from   w ww .  jav  a2  s.  c  o m
            }
        }
    }
}

From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            //                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabNormalTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*from ww w  .  j  ava 2s .  co  m*/
            }
        }
    }
}

From source file:com.freud.mrzz.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.tv_tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }// ww w .  j  a v a2 s .c om
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }
}

From source file:com.zaparound.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface);
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*from  w ww.  j  a va  2 s .  com*/
            }
        }
    }
}

From source file:android.percent.support.PercentLayoutHelper.java

private void supportPadding(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    int left = view.getPaddingLeft(), right = view.getPaddingRight(), top = view.getPaddingTop(),
            bottom = view.getPaddingBottom();
    PercentLayoutInfo.PercentVal percentVal = info.paddingLeftPercent;
    if (percentVal != null) {
        int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
        left = (int) (base * percentVal.percent);
    }//  w  w w .j  a  v a  2  s  . c  o  m
    percentVal = info.paddingRightPercent;
    if (percentVal != null) {
        int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
        right = (int) (base * percentVal.percent);
    }

    percentVal = info.paddingTopPercent;
    if (percentVal != null) {
        int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
        top = (int) (base * percentVal.percent);
    }

    percentVal = info.paddingBottomPercent;
    if (percentVal != null) {
        int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
        bottom = (int) (base * percentVal.percent);
    }
    view.setPadding(left, top, right, bottom);

}