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.yaly.ViewPagerDoubleIndicator.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.vpdi_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  w w. ja  v  a  2s  .c o m
            }
        }
    }
}

From source file:com.ranger.bmaterials.view.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        // v.setLayoutParams(expandedTabLayoutParams);
        // v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);
        } else {//from   www  . j a  v a  2  s  . c  o  m
            v.setPadding(tabPadding, 0, tabPadding, 0);
        }

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            // tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            if (i == 0)
                tab.setTextColor(tabTextColorSelected);
            // 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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java

public void addResultListItem(String title, String value, LinearLayout netLayout) {
    final float scale = activity.getResources().getDisplayMetrics().density;
    final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View measurementItemView = inflater.inflate(R.layout.classification_list_item, netLayout, false);

    final TextView itemTitle = (TextView) measurementItemView.findViewById(R.id.classification_item_title);
    itemTitle.setText(title);//from  w ww.j  av a2s .co  m

    final ImageView itemClassification = (ImageView) measurementItemView
            .findViewById(R.id.classification_item_color);
    itemClassification.setImageResource(Helperfunctions.getClassificationColor(-1));

    itemClassification.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.showHelp(R.string.url_help_result, false);
        }
    });

    final TextView itemValue = (TextView) measurementItemView.findViewById(R.id.classification_item_value);
    itemValue.setText(value);

    netLayout.addView(measurementItemView);

    final View divider = new View(activity);
    divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv, 1));
    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

    netLayout.addView(divider);

    netLayout.invalidate();
}

From source file:com.i370.ui.view.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);/*from  w w  w .  jav  a  2  s .  com*/
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //            System.out.println("===tab item click pos="+position);
            click2ScrollPage = true;
            pager.setCurrentItem(position);
        }
    });

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

From source file:ac.robinson.mediaphone.activity.TemplateBrowserActivity.java

private void initialiseTemplatesView() {
    mTemplates = (NarrativesListView) findViewById(R.id.list_templates);

    // for API 11 and above, buttons are in the action bar
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        LayoutInflater layoutInflater = getLayoutInflater();
        View headerRow = layoutInflater.inflate(R.layout.templates_header, null, false);
        mTemplates.addHeaderView(headerRow, null, false); // false = not selectable
        View emptyView = layoutInflater.inflate(R.layout.templates_empty, null, false);
        ((ViewGroup) mTemplates.getParent()).addView(emptyView);
        mTemplates.setEmptyView(emptyView); // must add separately as the header isn't shown when empty

    } else {// www .j a  v  a 2s  .  c  o m
        // initial empty list placeholder - add manually as the < v11 version includes the header row
        TextView emptyView = new TextView(TemplateBrowserActivity.this);
        emptyView.setGravity(Gravity.CENTER | Gravity.TOP);
        emptyView.setPadding(10,
                getResources().getDimensionPixelSize(R.dimen.template_list_empty_hint_top_padding), 10, 10); // temporary
        emptyView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        emptyView.setText(getString(R.string.template_list_empty));
        ((ViewGroup) mTemplates.getParent()).addView(emptyView);
        mTemplates.setEmptyView(emptyView);
    }

    mTemplateAdapter = new NarrativeAdapter(this, false, true);
    mTemplates.setAdapter(mTemplateAdapter);
    getSupportLoaderManager().initLoader(R.id.loader_templates_completed, null, this);
    mTemplates.setOnScrollListener(new ScrollManager());
    mTemplates.setOnTouchListener(new FingerTracker());
    mTemplates.setOnItemSelectedListener(new SelectionTracker());
    mTemplates.setOnItemClickListener(new NarrativeViewer());
}

From source file:zhwx.ui.dcapp.carmanage.view.PagerSlidingTabStrip.java

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

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

From source file:com.touch18.finaldemo.view.PagerSlidingTabStrip.java

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

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

From source file:com.futureinst.widget.PagerSlidingTabStrip.java

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

        }
    });

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

From source file:com.example.appdetail_optimization.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from  www  . j  av a  2s.c  o m
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (viewpagerStateListener != null) {
                viewpagerStateListener.onPageScrollStateChanged(1);
            }

            pager.setCurrentItem(position);
        }
    });

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

From source file:com.near.chimerarevo.fragments.ProductsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.products_grid_layout, container, false);

    boolean isLandscapeLarge = false;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
            isLandscapeLarge = true;/*ww w  .  ja  va 2  s  .  c o  m*/
    } else
        isLandscapeLarge = false;

    if (!isLandscapeLarge)
        v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0);

    GridView mGrid = (GridView) v.findViewById(R.id.products_grid);
    mCat = (Spinner) v.findViewById(R.id.category_spinner);
    mBrand = (Spinner) v.findViewById(R.id.brand_spinner);
    mLoading = (ProgressWheel) v.findViewById(R.id.product_progress);

    brandsList = new ArrayList<>();
    catList = new ArrayList<>();
    catIdList = new ArrayList<>();

    arrayList = new ArrayList<>();

    mAdapter = new ProductsAdapter(arrayList);
    if (mGrid != null) {
        mGrid.setAdapter(mAdapter);
        mGrid.setOnScrollListener(this);
        mGrid.setOnItemClickListener(this);
    }

    return v;
}