Example usage for android.widget TextView setBackgroundResource

List of usage examples for android.widget TextView setBackgroundResource

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:dev.drsoran.moloko.util.UIUtils.java

public final static void setListTasksCountView(TextView tasksCount, RtmListWithTaskCount list) {
    final int numTasks = list.getTaskCount();
    tasksCount.setText(String.valueOf(numTasks));

    if (list.hasSmartFilter()) {
        if (list.isSmartFilterValid()) {
            tasksCount.setBackgroundResource(R.drawable.tasklists_group_numtasks_bgnd_smart);
        } else {/*w  ww  . j a v  a  2s  . c  o  m*/
            tasksCount.setBackgroundResource(R.drawable.tasklists_group_numtasks_bgnd_smart_fail);
            tasksCount.setText("?");
        }
    } else {
        tasksCount.setBackgroundResource(R.drawable.tasklists_group_numtasks_bgnd);
    }
}

From source file:com.mappn.gfan.common.util.Utils.java

/**
 * Search Tab??TextViewView//from  w ww.  j  av  a2  s.  co m
 */
public static View createSearchTabView(Context context, String text) {
    TextView view = (TextView) LayoutInflater.from(context).inflate(R.layout.common_tab_view, null);
    view.setBackgroundResource(R.drawable.search_tab_selector);
    view.setTextAppearance(context, R.style.search_tab_text);
    view.setText(text);
    return view;
}

From source file:larry.baby.rain.common.view.TabPageIndicator.java

private void addTab(CharSequence text, int index) {
    Context context = getContext();
    DisplayMetrics dm = context.getResources().getDisplayMetrics();

    int padX = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 22, dm);
    int padY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, dm);

    TextView tabView = new TextView(context);
    tabView.setBackgroundResource(R.drawable.vpi__tab_indicator);
    tabView.setPadding(padX, padY, padX, padY);
    tabView.setGravity(Gravity.CENTER);/*from w  ww .ja v a2s .  com*/
    tabView.setTextColor(0xfff3f3f3);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    tabView.setTypeface(tabView.getTypeface(), Typeface.BOLD);
    tabView.setSingleLine();
    tabView.setTag(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this);
    tabView.setText(text);

    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
}

From source file:com.marshalchen.common.demoofui.pagerSlidingTabStrip.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.CENTER;/*from   ww  w  .  j  av a 2 s . c  om*/

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.jia.blossom.viewpageindicator.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from  www. jav a  2 s  . c  om
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));
    fl.addView(v);
    return fl;
}

From source file:com.kangsoo.pharmacy.activity.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*  w  ww  .  j  a v  a2 s.c o m*/

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));
    fl.addView(v);
    return fl;
}

From source file:cn.yunt.www.pagerslidingtabstrip.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//  w  ww. jav a  2 s  .  co m

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.marshalchen.common.demoofui.viewpagerSlidingTab.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from   w  w  w.  j a v  a2  s. c o m*/

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.vista.negocio.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from ww w.  jav a2 s . co m*/

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("Aqui poner una listta de item:    Nro " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.arta.lib.demo.widget.pagerslidingtabstrip.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from  w ww  .  ja va 2  s. c o  m

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.pagerslidingtabstrip_background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}