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, @Typeface.Style int style) 

Source Link

Document

Sets the typeface and style in which the text should be displayed, and turns on the fake bold and italic bits in the Paint if the Typeface that you provided does not have all the bits in the style that you specified.

Usage

From source file:mobisocial.musubi.objects.FileObj.java

@Override
public void getSummaryText(Context context, TextView view, FeedSummary summary) {
    JSONObject obj = summary.getJson();/*from   w  w w  . j  a va 2s .c om*/
    view.setTypeface(null, Typeface.ITALIC);
    view.setText(summary.getSender() + " posted a new file: " + obj.optString(FileObj.OBJ_FILENAME));
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW//from w  w w  . ja  v  a 2  s  .  c o m
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE TEXT ROW/*from w  w  w  .j  a va  2 s.  c  o m*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleTextRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView t2 = new TextView(context);
    t2.setText(att.get("value").equals("") ? " - " : att.get("value"));
    t2.setTextSize(11);
    t2.setGravity(Gravity.CENTER_HORIZONTAL);
    t2.setPadding(2, 0, 0, 2);
    t2.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(t2, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * DOUBLE IMAGE ROW//from  w  w w  .ja  v a  2  s  .c  om
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getDoubleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.3f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46,
            0.35f);
    ImageView img1 = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value1"));
    img1.setImageResource(context.getResources().getIdentifier(path, null, null));
    img1.setPadding(0, 3, 0, 3);
    container_layout.addView(img1, value_one_params);

    LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 46,
            0.35f);
    ImageView img2 = new ImageView(context);
    path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value2"));
    img2.setImageResource(context.getResources().getIdentifier(path, null, null));
    img2.setPadding(0, 3, 0, 3);
    container_layout.addView(img2, value_two_params);

    linear.addView(container_layout);

    return linear;
}

From source file:android.support.v7.widget.AppCompatTextHelper.java

private void onAsyncTypefaceReceived(WeakReference<TextView> textViewWeak, Typeface typeface) {
    if (mAsyncFontPending) {
        mFontTypeface = typeface;/* w  w  w  . j a v a 2  s .c  om*/
        final TextView textView = textViewWeak.get();
        if (textView != null) {
            textView.setTypeface(typeface, mStyle);
        }
    }
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * DOUBLE TEXT ROW/*from www  .  java 2  s.com*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getDoubleTextRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.3f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(2, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams value_one_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.35f);
    TextView t1 = new TextView(context);
    t1.setText(att.get("value1").equals("") ? " - " : att.get("value1"));
    t1.setTextSize(11);
    t1.setGravity(Gravity.CENTER_HORIZONTAL);
    t1.setPadding(2, 0, 0, 2);
    t1.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(t1, value_one_params);

    LinearLayout.LayoutParams value_two_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.35f);
    TextView t2 = new TextView(context);
    t2.setTextSize(11);
    t2.setText(att.get("value2").equals("") ? " - " : att.get("value2"));
    t2.setGravity(Gravity.CENTER_HORIZONTAL);
    t2.setPadding(2, 0, 0, 2);
    t2.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(t2, value_two_params);

    linear.addView(container_layout);

    return linear;
}

From source file:com.example.SmartBoard.MyActivity.java

/**
 * Called when the activity is first created.
 *///from w  ww .  j  a va 2s  .c  o m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    handler.usersAdapter = new UserListArrayAdapter(this, R.layout.online_list_message,
            handler.usersListHistory);
    listView = (ListView) findViewById(R.id.usersListView);

    getActionBar().setDisplayHomeAsUpEnabled(false); //disables up navigation

    TextView header = new TextView(this);
    header.setBackgroundColor(Color.parseColor("#FFF5EE"));

    header.setText("Designers:");
    header.setTypeface(null, Typeface.BOLD_ITALIC);

    header.setText(Html.fromHtml("<font color ='black'>D</font>" + "<font color ='blue'>e</font>"
            + "<font color = 'black'>s</font>" + "<font color ='red'>i</font>"
            + "<font color = 'black'>g</font>" + "<font color ='magenta'>n</font>"
            + "<font color = 'black'>e</font>" + "<font color ='blue'>r</font>"
            + "<font  color = 'black'>s</font>" + "<font color = 'black'>:</font>"

    ));

    listView.addHeaderView(header, "Online", false);
    listView.setAdapter(handler.usersAdapter);

    // handler.registerResources(getApplicationContext());
    drawer = (DrawingView) findViewById(R.id.drawing);
    handler.passDrawingContext(this);
}

From source file:org.npr.android.news.NewsListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.news_item, parent, false);
    }//from  w  w w . j av a2s  .com

    Story story = getItem(position);

    ImageView image = (ImageView) convertView.findViewById(R.id.NewsItemImage);
    TextView teaser = (TextView) convertView.findViewById(R.id.NewsItemTeaserText);
    TextView name = (TextView) convertView.findViewById(R.id.NewsItemNameText);

    if (story != null) {
        image.setImageDrawable(getContext().getResources()
                .getDrawable(isPlayable(story) ? R.drawable.icon_listen_main : R.drawable.bullet));
        image.setVisibility(View.VISIBLE);
        name.setTypeface(headlineTypeface, Typeface.NORMAL);
        name.setText(story.toString());
        String teaserText = story.getMiniTeaser();
        if (teaserText == null) {
            teaserText = story.getTeaser();
        }
        if (teaserText != null && teaserText.length() > 0) {
            // Disable for now.
            //        teaser.setText(story.getTeaser());
            //        teaser.setVisibility(View.VISIBLE);
        } else {
            teaser.setVisibility(View.INVISIBLE);
        }
        teaser.setVisibility(View.GONE);
    } else {
        // null marker means it's the end of the list.
        image.setVisibility(View.INVISIBLE);
        teaser.setVisibility(View.INVISIBLE);
        name.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
        name.setText(R.string.msg_load_more);
    }
    return convertView;
}

From source file:bigshots.people_helping_people.scroll_iew_lib.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {
            TextView tab = (TextView) v;
            tab.setTextSize(16);//from w  w w .  j  a  v a 2 s  . co m
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.carver.paul.truesight.Ui.CounterPicker.CounterPickerFragment.java

/**
 * Add a row detailing the advantages a particular hero has over the five in the photo.
 *
 * @param name/*from w  w w.  ja va  2 s . c o  m*/
 * @param advantages        This is a list of pairs, the string is the value of this hero's
 *                          advantage over that enemy. The boolean is whether or no the text
 *                          should be bold.
 * @param totalAdvantage
 */
protected void addRow(String name, List<Pair<String, Boolean>> advantages, String totalAdvantage) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    if (inflater == null)
        return;

    View itemView = inflater.inflate(R.layout.item_counter_picker, mCountersLinearLayout, false);
    if (itemView == null)
        return;

    TextView nameTextView = (TextView) itemView.findViewById(R.id.name);
    if (nameTextView == null)
        return;
    nameTextView.setText(name);

    for (int i = 0; i < advantages.size() && i < advantageTextViewIds.size(); i++) {
        TextView advTextView = (TextView) itemView.findViewById(advantageTextViewIds.get(i));
        if (advTextView == null)
            return;
        advTextView.setText(advantages.get(i).first);

        if (advantages.get(i).second) {
            advTextView.setTypeface(null, Typeface.BOLD);
        }
    }

    TextView totalAdvTextView = (TextView) itemView.findViewById(R.id.total_advantage);
    if (totalAdvantage == null)
        return;
    totalAdvTextView.setText(totalAdvantage);

    mCountersLinearLayout.addView(itemView);
}