Example usage for android.widget TextView setTypeface

List of usage examples for android.widget TextView setTypeface

Introduction

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

Prototype

public void setTypeface(@Nullable Typeface tf) 

Source Link

Document

Sets the typeface and style in which the text should be displayed.

Usage

From source file:com.autogermany.opel360.Utils.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 . j  av a2s  .c  om*/
 */
@SuppressLint("NewApi")
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.parseColor("#FFFFFF"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 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);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.development.jaba.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.  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);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    // By default use the unselected title color.
    textView.setTextColor(mTitleColor);

    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.example.sam.savemeapp.StatisticsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment.
    v = inflater.inflate(R.layout.fragment_statistics, container, false);
    fontLight = Typeface.createFromAsset(getContext().getAssets(), "panton_light.otf");
    fontBlack = Typeface.createFromAsset(getContext().getAssets(), "panton_black.otf");
    //Instead of having initializeObject in this fragment.
    //We declared them here since it didn't contain many layouts.
    mLegend = (LinearLayout) v.findViewById(R.id.legends);
    LinearLayout mLegendExtra = (LinearLayout) v.findViewById(R.id.legend_extra);
    params = mLegendExtra.getLayoutParams();
    TextView mStatistics = (TextView) v.findViewById(R.id.statistics_header);
    mStatistics.setTypeface(fontLight);
    return v;/*from   w w w  .  j  ava2 s.co  m*/
}

From source file:com.ashoksm.pinfinder.common.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  a  v a 2 s  .co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.parseColor("#99ffffff"));
    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:com.dreamspace.superman.UI.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)}.//w ww.j  a  v  a  2  s  .  co  m
 */
protected View createDefaultTabView(Context context) {
    View v;
    if (mIconAdapter == null) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT);
        textView.setAllCaps(true);
        textView.setTextColor(getStartColor());
        if (fillTheWidth) {
            textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1));
        } else {
            textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));

        }
        ;

        v = textView;
    } else {
        ImageView imgView = new TintImageView(context);
        imgView.setScaleType(ImageView.ScaleType.FIT_XY);
        imgView.setLayoutParams(new LinearLayout.LayoutParams(mTabIconSize, mTabIconSize));
        v = imgView;
    }

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

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

    return v;
}

From source file:com.example.alex.helloworld.SlidingTabLayout.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 ava 2 s .c o  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setTextColor(getResources().getColor(R.color.weiss));
    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));

    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:com.gh4a.activities.IssueCreateActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(Gh4Application.THEME);//from   w  w w .  j a  v  a2  s.  c  o  m
    super.onCreate(savedInstanceState);

    mSelectedLabels = new ArrayList<Label>();
    Bundle data = getIntent().getExtras();

    mRepoOwner = data.getString(Constants.Repository.OWNER);
    mRepoName = data.getString(Constants.Repository.NAME);
    mIssueNumber = data.getInt(Constants.Issue.NUMBER);

    if (hasErrorView()) {
        return;
    }

    if (!Gh4Application.get(this).isAuthorized()) {
        Intent intent = new Intent(this, Github4AndroidActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    setContentView(R.layout.issue_create);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(isInEditMode() ? getString(R.string.issue_edit_title, mIssueNumber)
            : getString(R.string.issue_create));
    actionBar.setSubtitle(mRepoOwner + "/" + mRepoName);
    actionBar.setDisplayHomeAsUpEnabled(true);

    TextView tvIssueLabelAdd = (TextView) findViewById(R.id.tv_issue_label_add);
    tvIssueLabelAdd.setTypeface(Gh4Application.get(this).boldCondensed);
    tvIssueLabelAdd.setTextColor(getResources().getColor(R.color.highlight));

    mTvSelectedMilestone = (TextView) findViewById(R.id.et_milestone);
    mTvSelectedAssignee = (TextView) findViewById(R.id.et_assignee);

    getSupportLoaderManager().initLoader(0, null, mLabelCallback);
    getSupportLoaderManager().initLoader(4, null, mIsCollaboratorCallback);
    if (isInEditMode()) {
        getSupportLoaderManager().initLoader(3, null, mIssueCallback);
    }
    setContentShown(!isInEditMode());
}

From source file:com.aniruddhc.acemusic.player.Dialogs.BlacklistedElementsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mApp = (Common) getActivity().getApplicationContext();

    final BlacklistedElementsDialog dialog = this;
    MANAGER_TYPE = getArguments().getString("MANAGER_TYPE");
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Get a cursor with a list of blacklisted elements.
    if (MANAGER_TYPE.equals("ARTISTS")) {
        builder.setTitle(R.string.blacklisted_artists);
        cursor = mApp.getDBAccessHelper().getBlacklistedArtists();

    } else if (MANAGER_TYPE.equals("ALBUMS")) {
        builder.setTitle(R.string.blacklisted_albums);
        cursor = mApp.getDBAccessHelper().getBlacklistedAlbums();

    } else if (MANAGER_TYPE.equals("SONGS")) {
        builder.setTitle(R.string.blacklisted_songs);
        cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs();

    } else if (MANAGER_TYPE.equals("PLAYLISTS")) {
        builder.setTitle(R.string.blacklisted_playlists);
        /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity());
        cursor = playlistsDBHelper.getAllBlacklistedPlaylists();*/

    } else {/*from  w  ww.  ja v a2s  .  c  o m*/
        Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show();
        return builder.create();
    }

    //Dismiss the dialog if there are no blacklisted elements.
    if (cursor.getCount() == 0) {
        Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
        return builder.create();
    }

    //Loop through checkboxStatuses and insert "TRUE" at every position by default.
    for (int i = 0; i < cursor.getCount(); i++) {
        checkboxStatuses.add(true);
    }

    View rootView = this.getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_blacklist_manager,
            null);
    TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text);
    ListView blacklistManagerListView = (ListView) rootView.findViewById(R.id.blacklist_manager_list);

    blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    blacklistManagerInfoText.setPaintFlags(
            blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    blacklistManagerListView.setFastScrollEnabled(true);
    BlacklistedElementsAdapter adapter = new BlacklistedElementsAdapter(getActivity(), cursor);
    blacklistManagerListView.setAdapter(adapter);

    builder.setView(rootView);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialog.dismiss();

        }

    });

    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Loop through checkboxStatuses and unblacklist the elements that have been unchecked.
            for (int i = 0; i < checkboxStatuses.size(); i++) {

                cursor.moveToPosition(i);
                if (checkboxStatuses.get(i) == true) {
                    //The item is still blacklisted.
                    continue;
                } else {
                    //The item has been unblacklisted.
                    if (MANAGER_TYPE.equals("ARTISTS")) {
                        mApp.getDBAccessHelper().setBlacklistForArtist(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false);

                    } else if (MANAGER_TYPE.equals("ALBUMS")) {
                        mApp.getDBAccessHelper().setBlacklistForAlbum(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM)),
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)), false);

                    } else if (MANAGER_TYPE.equals("SONGS")) {
                        mApp.getDBAccessHelper().setBlacklistForSong(
                                cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH)), false);

                    } else if (MANAGER_TYPE.equals("PLAYLISTS")) {
                        /*DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity());
                        playlistsDBHelper.unBlacklistPlaylist(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_BLACKLIST_STATUS)));*/

                    }

                }

            }

            dialog.dismiss();

        }

    });

    return builder.create();
}

From source file:com.aazamnawlakha.eac_android.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)}.//ww w .j  a  v  a 2 s  . co m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(context.getResources().getDimension(R.dimen.dimen_9_sp));
    textView.setTypeface(Typeface.DEFAULT);

    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(40, 20, 50, 20);

    return textView;
}

From source file:com.cyntwikip.android.phirelert.FireFeed.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  . ja  v a  2  s .  co m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);

    /* Edited Part */
    //for Fonts
    //Typeface face = Typeface.createFromAsset(context.getAssets(), "font/Roboto-Light.ttf");
    //textView.setTypeface(face);
    textView.setTypeface(Typeface.SANS_SERIF);

    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));

    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;
}