Example usage for android.view View setBackgroundResource

List of usage examples for android.view View setBackgroundResource

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:net.fengg.lib.tabsliding.TabSlidingView.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*ww w  . j  av a 2s  .  c o  m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        } else if (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;

            if (i == selectedPosition) {
                //?
                tab.setSelected(true);
            }
        } else {
            LinearLayout l = (LinearLayout) v;

            ImageButton icon = (ImageButton) l.getChildAt(0);
            icon.setBackgroundResource(tabBackgroundResId);
            icon.setSelected(false);
            if (i == selectedPosition) {
                icon.setSelected(true);
            }

            TextView text = (TextView) l.getChildAt(1);
            text.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            text.setTypeface(tabTypeface, tabTypefaceStyle);
            text.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) {
                    text.setAllCaps(true);
                } else {
                    text.setText(text.getText().toString().toUpperCase(locale));
                }
            }
            if (i == selectedPosition) {
                text.setTextColor(selectedTabTextColor);
            }

        }
    }

}

From source file:com.unkonw.testapp.libs.view.indicator.PagerSlidingTabStrip.java

private void updateTabStyles() {

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

        View v = tabsContainer.getChildAt(i);

        v.setLayoutParams(defaultTabLayoutParams);
        v.setBackgroundResource(tabBackgroundResId);
        if (shouldExpand) {
            v.setPadding(0, 0, 0, 0);//from ww  w  . j  a  v a 2s.  c om
        } else {
            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);
            if (i == 0) {
                tab.setTextSize(14);
                selectedBackground(tab);
                tab.setTextColor(getResources().getColor(indexColor));
            }

            else {
                tab.setBackgroundColor(backGroundColor);
                tab.setTextColor(tabTextColor);
                tab.setTextSize(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.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.nkdroid.tabpager.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        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 w  w  w.j  ava2s  .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:org.live.circle.component.PagerSlidingTabStrip.java

private void updateTabStyles() {
    if (tabView == null || tabView.length == 0) {
        return;/*from   w w w  .  ja v  a2s.co  m*/
    }
    for (int i = 0; i < tabView.length; i++) {
        View v = tabView[i];
        if (pager.getAdapter() != null && pager.getAdapter() instanceof CustomTabProvider) {
        } else {
            v.setBackgroundResource(tabBackgroundResId);
        }
        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);
            tab.setSelected(i == (pager != null ? pager.getCurrentItem() : 0));
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        } else if (v instanceof ImageView) {
            ImageView tab = (ImageView) v;
            tab.setSelected(i == (pager != null ? pager.getCurrentItem() : 0));
        }
    }
}

From source file:com.tdispatch.passenger.core.TDFragment.java

protected void lockUI(Boolean lockUI) {
    View v = mFragmentView.findViewById(R.id.tdfragment_busy_overlay_container);

    if (v != null) {

        AnimationDrawable busyAnim = (AnimationDrawable) ((ImageView) mFragmentView
                .findViewById(R.id.tdfragment_busy)).getBackground();

        if (lockUI) {
            //            // hide soft menu
            //            InputMethodManager imm = (InputMethodManager)mContext.getSystemService( Context.INPUT_METHOD_SERVICE);
            //            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

            if (getOverlayBackgroundResourceId() != null) {
                v.setBackgroundResource(getOverlayBackgroundResourceId());
            }/*from w w w  .j  av a  2 s.  co  m*/

            busyAnim.start();
            v.setVisibility(View.VISIBLE);
        } else {
            v.setVisibility(View.GONE);
            busyAnim.stop();
        }
    } else {
        WebnetLog.d("No lockUI overlay");
    }
}

From source file:com.wit.android.support.fragment.BaseFragment.java

/**
 *//*from w w  w . j a va  2 s  .c o m*/
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // Resolve view background.
    if (mContentView != null) {
        if (mContentView.backgroundRes() >= 0) {
            view.setBackgroundResource(mContentView.backgroundRes());
        }
    }
    // Set up clickable views.
    final ClickListener clickListener = new ClickListener();
    if (mClickableViewIds != null) {
        for (int id : mClickableViewIds) {
            View child = view.findViewById(id);
            if (child == null) {
                throw new NullPointerException("Clickable view with id(" + id + ") not found.");
            }
            child.setOnClickListener(clickListener);
        }
    }

    if (mViewsToInject != null) {
        for (Field field : mViewsToInject) {
            FragmentAnnotations.injectView(field, this, view, clickListener);
        }
    }
}

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));
                }/*from w  w  w  .  ja v a2 s  .  c  o  m*/
            }
        }
    }
}

From source file:com.astuetz.PagerSlidingTabStripPlus.java

private void updateTabStyles() {

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

        for (int k = 0; k < ((LinearLayout) tabsContainer.getChildAt(i)).getChildCount(); k++) {

            View v = ((LinearLayout) tabsContainer.getChildAt(i)).getChildAt(k);

            v.setBackgroundResource(tabBackgroundResId);

            if (v instanceof TextView) {

                TextView tab = (TextView) v;
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);

                // Setting color of textView
                if (textColorTab != null) {
                    tab.setTextColor(textColorTab);
                } else {
                    tab.setTextColor(Color.BLACK);
                }//w w  w  .j av a2s . 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.setAllCaps(true);
                    } else {
                        tab.setText(tab.getText().toString().toUpperCase(locale));
                    }
                }
            }
        }
    }
}

From source file:com.pranavpandey.smallapp.view.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        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);
            }/*ww  w  .ja  va 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: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  w w  w.j  a v a  2  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));
                }
            }
        }
    }
}