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.fjoglar.etsitnoticias.view.activities.NewsListActivity.java

private void setUpSearchView(MenuItem searchMenuItem, final MenuItem filterMenuItem) {
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));

    // Hide filter option when SearchView is expanded, restore it when collapsed.
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {
        @Override//ww w . ja  va  2s .c o m
        public boolean onMenuItemActionExpand(MenuItem item) {
            filterMenuItem.setVisible(false);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            filterMenuItem.setVisible(true);
            return true;
        }
    });
}

From source file:com.fobae.android.views.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.j  av a2  s . c  om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setTextColor(getResources().getColor(R.color.textPrimaryToolbar));
    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.bionx.res.DashMainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_new);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    initCards();//from   w w w .  j  a va 2 s .  com
    Appirater.appLaunched(this);

    Typeface tf = Typeface.createFromAsset(getAssets(), "SegoeWP-Semilight.ttf");

    TextView tv1 = (TextView) findViewById(R.id.textView1);
    tv1.setTypeface(tf);
    TextView tv2 = (TextView) findViewById(R.id.textView4);
    tv2.setTypeface(tf);
    TextView tv3 = (TextView) findViewById(R.id.textView5);
    tv3.setTypeface(tf);
    TextView tv4 = (TextView) findViewById(R.id.textView6);
    tv4.setTypeface(tf);
    TextView tv5 = (TextView) findViewById(R.id.textView7);
    tv5.setTypeface(tf);
    TextView tv6 = (TextView) findViewById(R.id.textView8);
    tv6.setTypeface(tf);
    TextView tv7 = (TextView) findViewById(R.id.ads);
    tv7.setTypeface(tf);

    SlidingMenu menu = new SlidingMenu(this);
    menu.setMode(SlidingMenu.LEFT);
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width);
    menu.setShadowDrawable(R.drawable.shadow);
    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.slide_menu);
}

From source file:com.example.drugsformarinemammals.Combined_Search.java

private void displayMessage(String messageTitle, String message) {
    AlertDialog.Builder myalert = new AlertDialog.Builder(this);

    TextView title = new TextView(this);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setTextSize(20);/*w  w  w  .  ja  v  a2s . co m*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText(messageTitle);
    title.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout layout = new LinearLayout(this);
    TextView text = new TextView(this);
    text.setTypeface(Typeface.SANS_SERIF);
    text.setTextSize(20);
    text.setPadding(10, 10, 10, 10);
    text.setText(message);
    layout.addView(text);

    myalert.setView(layout);
    myalert.setCustomTitle(title);
    myalert.setCancelable(true);
    myalert.show();

}

From source file:cc.mintcoin.wallet.ui.PeerListFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    adapter = new ArrayAdapter<Peer>(activity, 0) {
        @Override/*from   w w w. j av a  2  s.  co m*/
        public View getView(final int position, View row, final ViewGroup parent) {
            if (row == null)
                row = getLayoutInflater(null).inflate(R.layout.peer_list_row, null);

            final Peer peer = getItem(position);
            final VersionMessage versionMessage = peer.getPeerVersionMessage();
            final boolean isDownloading = peer.getDownloadData();

            final TextView rowIp = (TextView) row.findViewById(R.id.peer_list_row_ip);
            final InetAddress address = peer.getAddress().getAddr();
            final String hostname = hostnames.get(address);
            rowIp.setText(hostname != null ? hostname : address.getHostAddress());

            final TextView rowHeight = (TextView) row.findViewById(R.id.peer_list_row_height);
            final long bestHeight = peer.getBestHeight();
            rowHeight.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
            rowHeight.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowVersion = (TextView) row.findViewById(R.id.peer_list_row_version);
            rowVersion.setText(versionMessage.subVer);
            rowVersion.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowProtocol = (TextView) row.findViewById(R.id.peer_list_row_protocol);
            rowProtocol.setText("protocol: " + versionMessage.clientVersion);
            rowProtocol.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowPing = (TextView) row.findViewById(R.id.peer_list_row_ping);
            final long pingTime = peer.getPingTime();
            rowPing.setText(
                    pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
            rowPing.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            return row;
        }

        @Override
        public boolean isEnabled(final int position) {
            return false;
        }
    };
    setListAdapter(adapter);
}

From source file:com.cannabiscoin.wallet.ui.PeerListFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    adapter = new ArrayAdapter<Peer>(activity, 0) {
        @Override//from   w ww .jav  a 2  s . c o m
        public View getView(final int position, View row, final ViewGroup parent) {
            if (row == null)
                row = getLayoutInflater(null).inflate(R.layout.peer_list_row, null);

            final Peer peer = getItem(position);
            final VersionMessage versionMessage = peer.getPeerVersionMessage();
            final boolean isDownloading = peer.getDownloadData();

            final TextView rowIp = (TextView) row.findViewById(R.id.peer_list_row_ip);
            final InetAddress address = peer.getAddress().getAddr();
            final String hostname = hostnames.get(address);
            rowIp.setText(/*address.toString()*/hostname != null ? hostname : address.getHostAddress());

            final TextView rowHeight = (TextView) row.findViewById(R.id.peer_list_row_height);
            final long bestHeight = peer.getBestHeight();
            rowHeight.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
            rowHeight.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowVersion = (TextView) row.findViewById(R.id.peer_list_row_version);
            rowVersion.setText(versionMessage.subVer);
            rowVersion.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowProtocol = (TextView) row.findViewById(R.id.peer_list_row_protocol);
            rowProtocol.setText("protocol: " + versionMessage.clientVersion);
            rowProtocol.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowPing = (TextView) row.findViewById(R.id.peer_list_row_ping);
            final long pingTime = peer.getPingTime();
            rowPing.setText(
                    pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
            rowPing.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            return row;
        }

        @Override
        public boolean isEnabled(final int position) {
            return false;
        }
    };
    setListAdapter(adapter);
}

From source file:biz.wiz.android.wallet.ui.PeerListFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    adapter = new ArrayAdapter<Peer>(activity, 0) {
        private final LayoutInflater inflater = LayoutInflater.from(activity);

        @Override/*ww w . j av  a  2s  .  c o m*/
        public View getView(final int position, View row, final ViewGroup parent) {
            if (row == null)
                row = inflater.inflate(R.layout.peer_list_row, null);

            final Peer peer = getItem(position);
            final VersionMessage versionMessage = peer.getPeerVersionMessage();
            final boolean isDownloading = peer.getDownloadData();

            final TextView rowIp = (TextView) row.findViewById(R.id.peer_list_row_ip);
            final InetAddress address = peer.getAddress().getAddr();
            final String hostname = hostnames.get(address);
            rowIp.setText(hostname != null ? hostname : address.getHostAddress());

            final TextView rowHeight = (TextView) row.findViewById(R.id.peer_list_row_height);
            final long bestHeight = peer.getBestHeight();
            rowHeight.setText(bestHeight > 0 ? bestHeight + " blocks" : null);
            rowHeight.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowVersion = (TextView) row.findViewById(R.id.peer_list_row_version);
            rowVersion.setText(versionMessage.subVer);
            rowVersion.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowProtocol = (TextView) row.findViewById(R.id.peer_list_row_protocol);
            rowProtocol.setText("protocol: " + versionMessage.clientVersion);
            rowProtocol.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            final TextView rowPing = (TextView) row.findViewById(R.id.peer_list_row_ping);
            final long pingTime = peer.getPingTime();
            rowPing.setText(
                    pingTime < Long.MAX_VALUE ? getString(R.string.peer_list_row_ping_time, pingTime) : null);
            rowPing.setTypeface(isDownloading ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);

            return row;
        }

        @Override
        public boolean isEnabled(final int position) {
            return false;
        }
    };
    setListAdapter(adapter);
}

From source file:com.ibm.mil.readyapps.physio.activities.LandingActivity.java

private void setupToolbarWithDrawer() {
    landingMenuDrawer = (DrawerLayout) findViewById(R.id.landing_drawer_layout);
    menuItems = (ListView) findViewById(R.id.menu_list);
    menuItems.setOnItemClickListener(this);

    View header = getLayoutInflater().inflate(R.layout.menu_header, null);

    MenuAdapter menuAdapter = new MenuAdapter(this);
    menuAdapter.setUpHeader(header);//from w w w .  j a va 2 s  .c o  m
    menuItems.addHeaderView(header);
    menuItems.setAdapter(menuAdapter);
    Toolbar toolbar = new Toolbar(this);

    menuListener = new ActionBarDrawerToggle(this, landingMenuDrawer, toolbar, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            //switch menu icon to x icon
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.x_button);
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.menu_button);
        }
    };

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    LayoutInflater Inflator = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View toolbarView = Inflator.inflate(R.layout.toolbar, null);
    TextView titleText = (TextView) toolbarView.findViewById(R.id.title_text);

    Typeface robotoBold = AndroidUtils.robotoBold(this);
    titleText.setTypeface(robotoBold);

    ouchButton = (ImageButton) toolbarView.findViewById(R.id.ouch_button);
    ouchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PainLocationFragment fragment = new PainLocationFragment();
            if (!isCurrentFragment(fragment)) {
                getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment)
                        .addToBackStack(PainLocationFragment.class.getSimpleName()).commit();
                landingMenuDrawer.closeDrawer(menuItems);
            }
        }
    });

    actionBar = getSupportActionBar();
    actionBar.setCustomView(toolbarView, new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
            ActionBar.LayoutParams.WRAP_CONTENT));
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.black)));

    landingMenuDrawer.setDrawerListener(menuListener);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.menu_button);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

From source file:com.funny.developers.musicstylelist.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 .ja v a 2  s.c  om*/
 */
protected TextView createDefaultTabView(Context context, int tabViewWidth) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setWidth(tabViewWidth);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTextColor(mTextColor);
    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.android.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)}./*w  w w.ja  v a2 s .  co  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setSingleLine();
    textView.setEllipsize(TextUtils.TruncateAt.END);
    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));
    textView.setTextColor(Color.WHITE);
    int hpadding = (int) (TAB_VIEW_HORIZONTAL_PADDING_DIPS * getResources().getDisplayMetrics().density);
    int vpadding = (int) (TAB_VIEW_VERTICAL_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(hpadding, vpadding, hpadding, vpadding);
    return textView;
}