Example usage for android.util TypedValue COMPLEX_UNIT_SP

List of usage examples for android.util TypedValue COMPLEX_UNIT_SP

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_SP.

Prototype

int COMPLEX_UNIT_SP

To view the source code for android.util TypedValue COMPLEX_UNIT_SP.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is a scaled pixel.

Usage

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)}.//  www.ja  v a  2s . 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.jumpintorivet.rivet.components.sliding_tab.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)}./*  www  .  j a va  2  s .  c  o  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.setTextColor(Color.WHITE);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

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

    return textView;
}

From source file:com.launcher.silverfish.launcher.appdrawer.TabFragmentHandler.java

/**
 * Loads all tabs from the database./*w  w w . j a  v a  2s.  com*/
 */
public void loadTabs() {
    arrButton = new ArrayList<>();
    arrTabs = new ArrayList<>();

    LinearLayout tabWidget = (LinearLayout) rootView.findViewById(R.id.custom_tabwidget);

    LauncherSQLiteHelper sql = new LauncherSQLiteHelper((App) mActivity.getApplication());
    List<TabTable> tabTables = sql.getAllTabs();

    for (TabTable tabEntry : tabTables) {
        TabInfo tab = new TabInfo(tabEntry);
        arrTabs.add(tab);

        // Create a button for each tab
        Button btn = new Button(mActivity.getApplicationContext());
        btn.setText(tab.getLabel());
        btn.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_TEXT_SIZE);
        arrButton.add(btn);

        // Set the style of the button
        btn.setBackground(settings.getTabButtonStyle());
        btn.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT, 1));
        btn.setTextColor(settings.getFontFgColor());

        // Add the button to the tab widget.
        tabWidget.addView(btn);

        // And create a new tab
        TabHost.TabSpec tSpecFragmentId = tHost.newTabSpec(tab.getTag());
        tSpecFragmentId.setIndicator(tab.getLabel());
        tSpecFragmentId.setContent(new DummyTabContent(mActivity.getBaseContext()));
        tHost.addTab(tSpecFragmentId);
    }

}

From source file:com.al70b.core.extended_widgets.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  av  a 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.setTextColor(context.getResources().getColor(R.color.white));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

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

    return textView;
}

From source file:base.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from ww w.j a v  a  2 s .com*/
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    if (colorStateList != null) {
        tabTextColor = colorStateList;
    } else {
        tabTextColor = getColorStateList(textPrimaryColor);
    }

    underlineColor = textPrimaryColor;
    dividerColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, paddingLeft);
    paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, paddingRight);
    a.recycle();

    //In case we have the padding they must be equal so we take the biggest
    if (paddingRight < paddingLeft) {
        paddingRight = paddingLeft;
    }

    if (paddingLeft < paddingRight) {
        paddingLeft = paddingRight;
    }
    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);

    //tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);

    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
    tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
    tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.chalmers.schmaps.CheckBusActivity.java

/**
 * Makes the rows for the chalmerstable/*from   www.  j a  v  a 2s. co m*/
 */
public void makeChalmersRows() {
    for (int i = 0; i < NROFROWS; i++) {
        TableRow tempTableRow = new TableRow(this);
        tempTableRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        // Makes every other row light gray or white
        if (i % 2 == 0) {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_grey));
        } else {
            tempTableRow.setBackgroundColor(getResources().getColor(R.color.transp_white));
        }

        //Makes every textview for each column and add it before starting with a new one
        for (int j = 0; j < NR_OF_COLUMNS; j++) {
            TextView textview = new TextView(this);
            textview.setTextColor(Color.BLACK);
            textview.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
            //Check which content should be written in the textview
            if (j == COLUMN_NR_1) {
                textview.setText(chalmersLineArray.get(i));
            } else if (j == COLUMN_NR_2) {
                textview.setText(chalmersDestArray.get(i));
            } else if (j == COLUMN_NR_3) {
                textview.setText(chalmersTimeArray.get(i));
            } else if (j == COLUMN_NR_4) {
                textview.setText(chalmersTrackArray.get(i));
            }
            textview.setGravity(Gravity.CENTER_HORIZONTAL);
            tempTableRow.addView(textview);
        }
        chalmersTable.addView(tempTableRow,
                new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    }
}

From source file:android.olayinka.file.transfer.widget.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 www .  j a va2  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);

    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);
    //textView.setBackground(null);

    return textView;
}

From source file:com.github.takumalee.simplematerialtabpager.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from   w w  w.  ja  v a 2s  . co m
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)
    TypedArray a = context.obtainStyledAttributes(attrs, SystemAttributes.ATTRS);
    tabTextSize = a.getDimensionPixelSize(SystemAttributes.TEXT_SIZE_INDEX, tabTextSize);
    ColorStateList colorStateList = a.getColorStateList(SystemAttributes.TEXT_COLOR_INDEX);

    int textPrimaryColor = a.getColor(SystemAttributes.TEXT_COLOR_PRIMARY, android.R.color.white);
    underlineColor = textPrimaryColor;
    dividerColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;

    int padding = a.getDimensionPixelSize(SystemAttributes.PADDING_INDEX, 0);
    paddingLeft = padding > 0 ? padding : a.getDimensionPixelSize(SystemAttributes.PADDING_LEFT_INDEX, 0);
    paddingRight = padding > 0 ? padding : a.getDimensionPixelSize(SystemAttributes.PADDING_RIGHT_INDEX, 0);
    a.recycle();

    // get custom attrs
    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
    tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
    tabTextColorSelected = a.getColorStateList(R.styleable.PagerSlidingTabStrip_pstsTextColorSelected);
    textAlpha = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, textAlpha);
    a.recycle();

    tabTextColor = colorStateList == null
            ? getColorStateList(Color.argb(textAlpha, Color.red(textPrimaryColor),
                    Color.green(textPrimaryColor), Color.blue(textPrimaryColor)))
            : colorStateList;

    tabTextColorSelected = tabTextColorSelected == null ? getColorStateList(textPrimaryColor)
            : tabTextColorSelected;

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.spoiledmilk.cykelsuperstier.break_rote.TransportationActivity.java

private void initStrings() {
    ((TextView) findViewById(R.id.textFrom)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textFrom)).setText(CykelsuperstierApplication.getString("from") + ":");
    ((TextView) findViewById(R.id.textFromStation)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textFromStation)).setText(fromStation + " st");
    ((TextView) findViewById(R.id.textToStation)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textToStation)).setText(toStation + " st");
    String currentTime = "";
    Calendar calendar = Calendar.getInstance();
    int hours = calendar.get(Calendar.HOUR_OF_DAY);
    int mins = calendar.get(Calendar.MINUTE) + minutesToAStation;
    hours += mins / 60;//from  w  w w  .  ja  v  a 2 s . c  om
    mins = mins % 60;
    currentTime += calendar.get(Calendar.DAY_OF_MONTH) + ". " + monthString(calendar.get(Calendar.MONTH)) + " "
            + calendar.get(Calendar.YEAR) + ", " + CykelsuperstierApplication.getString("departure") + ". "
            + CykelsuperstierApplication.getString("at") + ". " + (hours < 10 ? "0" + hours : hours + "") + ":"
            + (mins < 10 ? "0" + mins : "" + mins);
    ((TextView) findViewById(R.id.textCurrentTime)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textCurrentTime)).setText(currentTime);
    ((TextView) findViewById(R.id.textTo)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTo)).setText(CykelsuperstierApplication.getString("to") + ":");
    ((TextView) findViewById(R.id.textTime)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTime)).setText(CykelsuperstierApplication.getString("time") + ":");
    ((TextView) findViewById(R.id.textDeparture)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textDeparture))
            .setText(CykelsuperstierApplication.getString("departure") + ".");
    ((TextView) findViewById(R.id.textArrival)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textArrival)).setText(CykelsuperstierApplication.getString("arrival") + ".");
    ((TextView) findViewById(R.id.textArrivalTime)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textArrivalTime)).setText(CykelsuperstierApplication.getString("time"));
    ((TextView) findViewById(R.id.textShift)).setTypeface(CykelsuperstierApplication.getBoldFont());
    ((TextView) findViewById(R.id.textShift)).setText(CykelsuperstierApplication.getString("shift"));
    ((TextView) findViewById(R.id.textTitle)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    ((TextView) findViewById(R.id.textTitle)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTitle))
            .setText(CykelsuperstierApplication.getString("recommended_routes"));
    ((TextView) findViewById(R.id.textDeparture1)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textDeparture2)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textDeparture3)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textArrival1)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textArrival2)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textArrival3)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTime1)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTime2)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textTime3)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textShift1)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textShift2)).setTypeface(CykelsuperstierApplication.getNormalFont());
    ((TextView) findViewById(R.id.textShift3)).setTypeface(CykelsuperstierApplication.getNormalFont());
}

From source file:com.ape.cloudfile.widget.vpi.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId, int count) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;/*w  w  w. j av a  2  s .co m*/
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    tabView.setGravity(Gravity.CENTER);
    tabView.setPadding(0, 15, 0, 15);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    tabView.setTextColor(getResources().getColorStateList(R.color.myos_tab_text_color));

    //        if (iconResId != 0) {
    //            tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
    //        }

    if (count > 1) {
        tabView.setBackgroundResource(R.drawable.action_tab_background);
    } else {
        tabView.setBackgroundResource(R.drawable.tinno_title_bg_holo_light);
        tabView.setTextColor(getResources().getColor(R.color.tab_bar_title_color));
        tabView.setPadding(20, 0, 0, 0);
        tabView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        Drawable drawable = getResources().getDrawable(R.drawable.title_panel_back);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        tabView.setCompoundDrawables(drawable, null, null, null);
    }

    //add by zjw
    //        if(index == 0)
    //        {
    //           tabView.setBackgroundResource(R.drawable.title_bar_left_selector);
    //        }else if(index == (count - 1))
    //        {
    //           tabView.setBackgroundResource(R.drawable.title_bar_right_selector);
    //        }else
    //        {
    //           tabView.setBackgroundResource(R.drawable.title_bar_middle_selector);
    //        }

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