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:com.app.learn.Util.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from ww  w.j av  a2 s  .co  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView;
    textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    textView.setTextColor(Color.WHITE); // \(^o^)/ ???? TextColor

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.ciandt.thegarage.navapp.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   ww w. j av  a  2  s .c  om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);

    //TypefaceUtil.loadCustomFonts(context, Constants.Font.MUSEO_REGULAR500, textView);

    textView.setTextColor(context.getResources().getColor(android.R.color.white));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding + 20, padding, padding + 20, padding);

    return textView;
}

From source file:com.t28.draggableview.demo.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   w w w  .  ja  v a2 s.c o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setLayoutParams(
            new SlidingTabStrip.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:helpers.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* ww  w  .  j  a v a2 s . c  o m*/
 */
protected View createDefaultTabView(Context context) {

    TextView textView = new TextView(context);

    //textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.location, 0);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int paddingWidth = (int) (TAB_VIEW_PADDING_DIPS_WIDTH * getResources().getDisplayMetrics().density);
    int paddingHeight = (int) (TAB_VIEW_PADDING_DIPS_HEIGHT * getResources().getDisplayMetrics().density);
    textView.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);

    return textView;
}

From source file:com.abewy.android.apps.klyph.app.MainActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    if (notificationsFragment != null && menu.findItem(R.id.menu_notifications) == null) {
        final MenuItem notificationItem = menu.add(Menu.NONE, R.id.menu_notifications, 2,
                R.string.menu_notifications);
        notificationItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        notificationItem.setActionView(R.layout.actionbar_item_notifications);

        final TextView notificationTextView = (TextView) notificationItem.getActionView()
                .findViewById(R.id.textView);

        int count = notificationsFragment.getUnreadCount();

        notificationTextView.setText(String.valueOf(count));

        if (count > 0) {
            notificationTextView
                    .setBackgroundResource(AttrUtil.getResourceId(this, R.attr.notificationsItemBackground));
        } else {//from ww w  .j  a v a2s. c o m
            notificationTextView.setBackgroundResource(R.drawable.notifications_read_background);

        }

        notificationItem.getActionView().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                onOptionsItemSelected(notificationItem);
            }
        });
    }

    if (!KlyphFlags.IS_PRO_VERSION && menu.findItem(R.id.menu_buy_pro) == null) {
        menu.add(Menu.NONE, R.id.menu_buy_pro, 2, R.string.menu_buy_pro)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (menu.findItem(R.id.menu_faq) == null) {
        menu.add(Menu.NONE, R.id.menu_faq, Menu.NONE, R.string.menu_faq)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:com.clairvoyant.Components.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w  ww.ja va  2  s.  co m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    //        textView.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
    //              50, 1f));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    //        int padding = TAB_VIEW_PADDING_DIPS;
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.example.chicharo.clean_ambar.util.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.// w  w w. j  a  v a 2  s .c  o m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); //
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, //Ripple effect
                outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

/**
 * Show a content header. A content header provides information about the current Collection
 * object that the user has navigated to. Like an AlbumArt image with the {@link
 * org.runbuddy.libtomahawk.collection.Album}s name, which is shown at the top of the listview,
 * if the user browses to a particular {@link org.runbuddy.libtomahawk.collection.Album} in his
 * {@link org.runbuddy.libtomahawk.collection.UserCollection}.
 *
 * @param item the Collection object's information to show in the header view
 *//*  www . ja v  a  2 s.  co m*/
protected void showContentHeader(final Object item) {
    if (getView() == null) {
        Log.e(TAG, "Couldn't setup content header, because getView() is null!");
        return;
    }

    boolean isPagerFragment = this instanceof PagerFragment;

    //Inflate content header
    int stubResId;
    int inflatedId;
    if (item instanceof User) {
        stubResId = isPagerFragment ? R.id.content_header_user_pager_stub : R.id.content_header_user_stub;
        inflatedId = isPagerFragment ? R.id.content_header_user_pager : R.id.content_header_user;
    } else {
        if (mHeaderScrollableHeight > 0) {
            stubResId = isPagerFragment ? R.id.content_header_pager_stub : R.id.content_header_stub;
            inflatedId = isPagerFragment ? R.id.content_header_pager : R.id.content_header;
        } else {
            stubResId = isPagerFragment ? R.id.content_header_static_pager_stub
                    : R.id.content_header_static_stub;
            inflatedId = isPagerFragment ? R.id.content_header_static_pager : R.id.content_header_static;
        }
    }
    final View contentHeader = ViewUtils.ensureInflation(getView(), stubResId, inflatedId);
    contentHeader.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;

    //Now we fill the added views with data and inflate the correct imageview_grid depending on
    //what we need
    final int gridOneStubId = isPagerFragment ? R.id.imageview_grid_one_pager_stub
            : R.id.imageview_grid_one_stub;
    final int gridOneResId = isPagerFragment ? R.id.imageview_grid_one_pager : R.id.imageview_grid_one;
    if (item instanceof Integer) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageView, (Integer) item);
    } else if (item instanceof String) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), imageView, (String) item);
    } else if (item instanceof ColorDrawable) {
        View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
        v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
        ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
        imageView.setImageDrawable((ColorDrawable) item);
    } else if (mHeaderScrollableHeight > 0) {
        View moreButton = getView().findViewById(R.id.more_button);//+?button
        moreButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentUtils.showContextMenu((TomahawkMainActivity) getActivity(), item, mCollection.getId(),
                        false, mHideRemoveButton);
            }
        });

        if (item instanceof Album) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Album) item).getImage(),
                    Image.getLargeImageSize(), false);
            View stationButton = getView().findViewById(R.id.station_button);
            stationButton.setVisibility(View.VISIBLE);
            stationButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getMediaController() != null) {
                        List<Pair<Artist, String>> artists = new ArrayList<>();
                        artists.add(new Pair<>(((Album) item).getArtist(), ""));
                        StationPlaylist stationPlaylist = StationPlaylist.get(artists, null, null);
                        if (stationPlaylist != getPlaybackManager().getPlaylist()) {
                            getPlaybackManager().setPlaylist(stationPlaylist);
                            getMediaController().getTransportControls().play();
                        }
                    }
                }
            });
        } else if (item instanceof Artist) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Artist) item).getImage(),
                    Image.getLargeImageSize(), true);
            View stationButton = getView().findViewById(R.id.station_button);
            stationButton.setVisibility(View.VISIBLE);
            stationButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getMediaController() != null) {
                        List<Pair<Artist, String>> artists = new ArrayList<>();
                        artists.add(new Pair<>((Artist) item, ""));
                        StationPlaylist stationPlaylist = StationPlaylist.get(artists, null, null);
                        if (stationPlaylist != getPlaybackManager().getPlaylist()) {
                            getPlaybackManager().setPlaylist(stationPlaylist);
                            getMediaController().getTransportControls().play();
                        }
                    }
                }
            });
        } else if (item instanceof Playlist) {
            ViewHolder.fillView(getView(), (Playlist) item,
                    mHeaderNonscrollableHeight + mHeaderScrollableHeight, isPagerFragment);
            View stationButton = getView().findViewById(R.id.station_button);
            stationButton.setVisibility(View.VISIBLE);
            stationButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getMediaController() != null) {
                        StationPlaylist stationPlaylist = StationPlaylist.get((Playlist) item);
                        if (stationPlaylist != getPlaybackManager().getPlaylist()) {
                            getPlaybackManager().setPlaylist(stationPlaylist);
                            getMediaController().getTransportControls().play();
                        }
                    }
                }
            });
        } else if (item instanceof Query) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            ImageUtils.loadImageIntoImageView(TomahawkApp.getContext(), imageView, ((Query) item).getImage(),
                    Image.getLargeImageSize(), ((Query) item).hasArtistImage());
        }
    } else {
        if (item == null) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageView imageView = (ImageView) v.findViewById(R.id.imageview1);
            imageView.setImageDrawable(
                    new ColorDrawable(getResources().getColor(R.color.userpage_default_background)));
        } else if (item instanceof Image) {
            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
            ImageUtils.loadBlurredImageIntoImageView(TomahawkApp.getContext(),
                    (ImageView) v.findViewById(R.id.imageview1), (Image) item, Image.getSmallImageSize(),
                    R.color.userpage_default_background);
        } else if (item instanceof User) {
            User.getSelf().done(new DoneCallback<User>() {
                @Override
                public void onDone(final User user) {
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            boolean showFollowing = false;
                            boolean showNotFollowing = false;
                            if (mShowFakeFollowing || mShowFakeNotFollowing) {
                                showFollowing = mShowFakeFollowing;
                                showNotFollowing = mShowFakeNotFollowing;
                            } else if (!user.isOffline()) {
                                showFollowing = item != user && user.getFollowings() != null
                                        && user.getFollowings().containsKey(item);
                                showNotFollowing = item != user && (user.getFollowings() == null
                                        || !user.getFollowings().containsKey(item));
                            }
                            View v = ViewUtils.ensureInflation(getView(), gridOneStubId, gridOneResId);
                            v.getLayoutParams().height = mHeaderNonscrollableHeight + mHeaderScrollableHeight;
                            ImageUtils.loadBlurredImageIntoImageView(TomahawkApp.getContext(),
                                    (ImageView) v.findViewById(R.id.imageview1), ((User) item).getImage(),
                                    Image.getSmallImageSize(), R.color.userpage_default_background);
                            ImageUtils.loadUserImageIntoImageView(TomahawkApp.getContext(),
                                    (ImageView) contentHeader.findViewById(R.id.userimageview1), (User) item,
                                    Image.getSmallImageSize(),
                                    (TextView) contentHeader.findViewById(R.id.usertextview1));
                            TextView textView = (TextView) contentHeader.findViewById(R.id.textview1);
                            textView.setText(((User) item).getName().toUpperCase());
                            TextView followButton = (TextView) contentHeader.findViewById(R.id.followbutton1);
                            if (showFollowing) {
                                followButton.setVisibility(View.VISIBLE);
                                followButton.setBackgroundResource(
                                        R.drawable.selectable_background_button_green_filled);
                                followButton.setOnClickListener(mFollowButtonListener);
                                followButton.setText(TomahawkApp.getContext()
                                        .getString(R.string.content_header_following).toUpperCase());
                            } else if (showNotFollowing) {
                                followButton.setVisibility(View.VISIBLE);
                                followButton
                                        .setBackgroundResource(R.drawable.selectable_background_button_green);
                                followButton.setOnClickListener(mFollowButtonListener);
                                followButton.setText(TomahawkApp.getContext()
                                        .getString(R.string.content_header_follow).toUpperCase());
                            } else {
                                followButton.setVisibility(View.GONE);
                            }
                        }
                    });
                }
            });
        }
    }
}

From source file:com.open.imooc.widght.tab.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//  ww  w  .j ava  2 s. co  m
 */
protected TextView createDefaultTabView(CharSequence title) {
    TextView textView = new TextView(getContext());
    textView.setGravity(Gravity.CENTER);
    textView.setText(title);
    //        textView.setTextColor(tabViewTextColors);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabViewTextSize);
    textView.setTypeface(Typeface.DEFAULT);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    if (tabViewBackgroundResId != NO_ID) {
        textView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(tabViewTextAllCaps);
    }

    textView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        textView.setMinWidth(tabViewTextMinWidth);
    }

    return textView;
}

From source file:com.artech.controls.tabs.SlidingTabLayout.java

@SuppressLint("NewApi")
protected void applyDefaultTabViewStyle(TextView textView) {
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }//from w w  w  .  j  a  va  2s. com

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    if (mDistributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) textView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
    }
}