Example usage for android.view View setPadding

List of usage examples for android.view View setPadding

Introduction

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

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:net.arvin.afbaselibrary.widgets.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);// w w  w  .j  a  v a2 s .co m
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            clear = false;
            pager.setCurrentItem(position);
            if (onTabClickListener != null) {
                onTabClickListener.onClick(position);
            }
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.paginatedgallery.PaginatedGalleryAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenWidth / viewsPerPage));

    int size = images.size();

    //      Log.i(TAG, "Position: "+position + " , Size : "+size);
    for (int i = 0; i < viewsPerPage; i++) {
        final int index = position + (position * (viewsPerPage - 1)) + i;
        Log.i(TAG, "Index: " + index + " , Size : " + size);
        if (index < size) {
            View imageView;
            if (isImageUrl) {
                imageView = new RemoteImageView(context, (String) images.get(index), errorDrawable,
                        errorDrawable, true);
            } else {
                imageView = new ImageView(context);
                ((ImageView) imageView).setImageDrawable((Drawable) images.get(index));
            }//from w w  w  .j  a  va  2 s  . c  o m

            //            imageView.setTag(index);
            imageView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (mItemClickListener != null) {
                        mItemClickListener.onItemClick(v, index);
                    }
                }
            });
            imageView.setLayoutParams(new LayoutParams(screenWidth / viewsPerPage, screenWidth / viewsPerPage));
            imageView.setPadding(10, 10, 10, 10);
            layout.addView(imageView);
        }
    }

    ((ViewPager) collection).addView(layout);

    return layout;
}

From source file:com.summer.helper.view.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from ww w.ja  v a  2 s  .com
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
            if (currentPosition == position) {
                if (notifyCurListener != null) {
                    notifyCurListener.notifyCur();
                }

            }
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    //expandedTabLayoutParams.width = SUtils.getSWidth((Activity) context,125);
    Logs.i("shouldExpand:" + shouldExpand + "," + expandedTabLayoutParams.width);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);/*w  w  w. j a  v a  2  s .c  o  m*/
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mOnViewPagerSwitchedListener != null) {
                mOnViewPagerSwitchedListener.onPageSwitched();
            }
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:scroll.com.rdemo.scroll.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from   w  ww .java 2 s.  com
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // ?
            if (isItemClickEnable) {
                pager.setCurrentItem(position);
            }
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from   ww  w .j  a  v  a2s .co  m
    tab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (pager.getCurrentItem() == position && onTabClickListener != null) {
                onTabClickListener.onCurrentTabClicked(position);
            } else {
                pager.setCurrentItem(position, true);
            }
        }
    });
    addTabDoubleTapListener(position, tab);
    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, tabViewLayoutParams);
}

From source file:kr.co.nqk.rfa.customview.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//  w  ww  .j  a v a  2s .  c  om
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (delegateTabClickListener != null)
                delegateTabClickListener.onTabClick(position);

            pager.setCurrentItem(position);
        }
    });

    //      tab.setPadding(tabPadding, tabPaddingTopBottom, tabPadding, tabPaddingTopBottom);
    tab.setPadding(tabPadding, 0, tabPadding, 0);
    LinearLayout.LayoutParams lp = shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams;
    lp.leftMargin = tabMargin;
    lp.rightMargin = tabMargin;
    if (tabWidth != 0) {
        lp.width = tabWidth;
    }

    tabsContainer.addView(tab, position, lp);
}

From source file:com.yan.stamped.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/*  w  w  w. j a va2 s .c o  m*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTextColor(Color.WHITE);
        tabView.setOnClickListener(tabClickListener);
        tabView.setPadding(tabView.getPaddingLeft() + 27, tabView.getPaddingTop(),
                tabView.getPaddingRight() + 27, tabView.getPaddingBottom());
        mTabStrip.addView(tabView);
    }
}

From source file:net.ibaixin.chat.view.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//  w w  w. jav a  2s .  c  o m
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    mTabLayout.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:yjbo.yy.ynewsrecycle.mainutil.PSFirst.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        //            v.setBackgroundResource(mTabBackgroundResId);
        if (i == mTabCount - 1) {//??
            float dimension = mcontext.getResources().getDimension(R.dimen.text_50);
            v.setPadding(mTabPadding, v.getPaddingTop(), (int) dimension, v.getPaddingBottom());
        } else {/*  w ww.j  av  a  2  s. co m*/
            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.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));
                }
            }
            if (tab_title.isSelected()) {
                //    LogUtils.i("------" + i);
                //  tab_title.setTextColor(Color.parseColor("#ffffff"));
                tab_title.setTextColor(Color.parseColor("#29b4ed"));
                this.setIndicatorHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0,
                        getResources().getDisplayMetrics()));
                //  tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,mcontext.getResources().getDimension(R.dimen.honor_card_awesome_item_head_size));
                //                    tab_title.setTextSize(16);
                //                    TextPaint tp = tab_title.getPaint();
                //                    tp.setFakeBoldText(true);
                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
            } else {
                //    LogUtils.i("------" + i);

                this.setIndicatorHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0,
                        getResources().getDisplayMetrics()));
                //                    tab_title.setTextColor(getResources().getColor(R.color.tab_default_text));
                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabTextSize);
                tab_title.setTextColor(Color.parseColor("#666666"));
                //                    TextPaint tp = tab_title.getPaint();
                //                    tp.setFakeBoldText(false);
            }
        }
    }
}