Example usage for android.graphics Typeface SERIF

List of usage examples for android.graphics Typeface SERIF

Introduction

In this page you can find the example usage for android.graphics Typeface SERIF.

Prototype

Typeface SERIF

To view the source code for android.graphics Typeface SERIF.

Click Source Link

Document

The NORMAL style of the default serif typeface.

Usage

From source file:com.farmerbb.notepad.adapter.NoteListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    NoteListItem item = getItem(position);
    String note = item.getNote();

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout, parent, false);

    // Lookup view for data population
    TextView noteTitle = convertView.findViewById(R.id.noteTitle);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);//from w w w.  j a v  a  2 s .  c  o  m

    // Apply theme
    SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light"))
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary));

    if (theme.contains("dark"))
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark));

    if (theme.contains("sans"))
        noteTitle.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteTitle.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteTitle.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteTitle.setTextSize(12);
        break;
    case "small":
        noteTitle.setTextSize(14);
        break;
    case "normal":
        noteTitle.setTextSize(16);
        break;
    case "large":
        noteTitle.setTextSize(18);
        break;
    case "largest":
        noteTitle.setTextSize(20);
        break;
    }

    // Return the completed view to render on screen
    return convertView;
}

From source file:com.anjalimacwan.adapter.NoteListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    NoteListItem item = getItem(position);
    String note = item.getNote();

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout, parent, false);

    // Lookup view for data population
    TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);//from   w  w  w .ja  v a  2 s.  c  o  m

    // Apply theme
    SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light"))
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary));

    if (theme.contains("dark"))
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark));

    if (theme.contains("sans"))
        noteTitle.setTypeface(Typeface.SANS_SERIF);

    if (theme.contains("serif"))
        noteTitle.setTypeface(Typeface.SERIF);

    if (theme.contains("monospace"))
        noteTitle.setTypeface(Typeface.MONOSPACE);

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteTitle.setTextSize(12);
        break;
    case "small":
        noteTitle.setTextSize(14);
        break;
    case "normal":
        noteTitle.setTextSize(16);
        break;
    case "large":
        noteTitle.setTextSize(18);
        break;
    case "largest":
        noteTitle.setTextSize(20);
        break;
    }

    // Return the completed view to render on screen
    return convertView;
}

From source file:com.farmerbb.notepad.adapter.NoteListDateAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    NoteListItem item = getItem(position);
    String note = item.getNote();
    String date = item.getDate();

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false);

    // Lookup view for data population
    TextView noteTitle = convertView.findViewById(R.id.noteTitle);
    TextView noteDate = convertView.findViewById(R.id.noteDate);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);//from   w  w w  .  ja v  a2 s  .  c o m
    noteDate.setText(date);

    // Apply theme
    SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary));
    }

    if (theme.contains("dark")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark));
    }

    if (theme.contains("sans")) {
        noteTitle.setTypeface(Typeface.SANS_SERIF);
        noteDate.setTypeface(Typeface.SANS_SERIF);
    }

    if (theme.contains("serif")) {
        noteTitle.setTypeface(Typeface.SERIF);
        noteDate.setTypeface(Typeface.SERIF);
    }

    if (theme.contains("monospace")) {
        noteTitle.setTypeface(Typeface.MONOSPACE);
        noteDate.setTypeface(Typeface.MONOSPACE);
    }

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteTitle.setTextSize(12);
        noteDate.setTextSize(8);
        break;
    case "small":
        noteTitle.setTextSize(14);
        noteDate.setTextSize(10);
        break;
    case "normal":
        noteTitle.setTextSize(16);
        noteDate.setTextSize(12);
        break;
    case "large":
        noteTitle.setTextSize(18);
        noteDate.setTextSize(14);
        break;
    case "largest":
        noteTitle.setTextSize(20);
        noteDate.setTextSize(16);
        break;
    }

    // Return the completed view to render on screen
    return convertView;
}

From source file:com.anjalimacwan.adapter.NoteListDateAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    NoteListItem item = getItem(position);
    String note = item.getNote();
    String date = item.getDate();

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false);

    // Lookup view for data population
    TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle);
    TextView noteDate = (TextView) convertView.findViewById(R.id.noteDate);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);/*from   w  w  w.j  a  v a 2 s. c  o m*/
    noteDate.setText(date);

    // Apply theme
    SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary));
    }

    if (theme.contains("dark")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark));
    }

    if (theme.contains("sans")) {
        noteTitle.setTypeface(Typeface.SANS_SERIF);
        noteDate.setTypeface(Typeface.SANS_SERIF);
    }

    if (theme.contains("serif")) {
        noteTitle.setTypeface(Typeface.SERIF);
        noteDate.setTypeface(Typeface.SERIF);
    }

    if (theme.contains("monospace")) {
        noteTitle.setTypeface(Typeface.MONOSPACE);
        noteDate.setTypeface(Typeface.MONOSPACE);
    }

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteTitle.setTextSize(12);
        noteDate.setTextSize(8);
        break;
    case "small":
        noteTitle.setTextSize(14);
        noteDate.setTextSize(10);
        break;
    case "normal":
        noteTitle.setTextSize(16);
        noteDate.setTextSize(12);
        break;
    case "large":
        noteTitle.setTextSize(18);
        noteDate.setTextSize(14);
        break;
    case "largest":
        noteTitle.setTextSize(20);
        noteDate.setTextSize(16);
        break;
    }

    // Return the completed view to render on screen
    return convertView;
}

From source file:com.view.widget.SlidingTabLayout.java

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.SERIF, Typeface.BOLD);

    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, 0, padding, padding);

    return textView;
}

From source file:com.guerinet.formgenerator.demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    LinearLayout container = (LinearLayout) findViewById(R.id.container);

    //Get the default instance
    FormGenerator fg = FormGenerator.bind(this, container);

    //Default Form
    fg.text("Form Item: Text (default settings)").build();

    fg.text("Form Item: Button").onClick(new TextViewFormItem.OnClickListener() {
        @Override//from  ww  w.j  ava  2  s. co  m
        public void onClick(TextViewFormItem item) {
            Toast.makeText(MainActivity.this, "Form Item: Button Clicked", Toast.LENGTH_SHORT).show();

        }
    }).build();

    fg.space();

    fg.button("Form Item, Simple Button").onClick(new TextViewFormItem.OnClickListener() {
        @Override
        public void onClick(TextViewFormItem item) {
            Toast.makeText(MainActivity.this, "Form Item: Simple Button Clicked", Toast.LENGTH_SHORT).show();
        }
    }).build();

    fg.borderlessButton("Form Item, Borderless Button").onClick(new TextViewFormItem.OnClickListener() {
        @Override
        public void onClick(TextViewFormItem item) {
            Toast.makeText(MainActivity.this, "Form Item: Borderless Button Clicked", Toast.LENGTH_SHORT)
                    .show();
        }
    }).layoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT), Gravity.CENTER).build();

    fg.space();
    fg.line();

    fg.input("").hint("Form Item: Input").build();

    fg.aSwitch("Form Item: Switch").onCheckChanged(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Toast.makeText(MainActivity.this, "Form Item: Switch changed", Toast.LENGTH_SHORT).show();
        }
    }).build();

    fg.space();
    fg.space();
    fg.space();
    fg.space();

    //Custom Form
    fg = new FormGenerator.Builder().setDefaultBackground(android.R.drawable.list_selector_background)
            .setDefaultLineColorId(android.R.color.black)
            .setDefaultTextColor(ContextCompat.getColor(this, android.R.color.holo_red_dark))
            .setDefaultTypeface(Typeface.SERIF)
            .setDefaultIconColor(ContextCompat.getColor(this, android.R.color.holo_blue_dark))
            .bind(this, container);

    //Add the different form items
    fg.text("Form Item: Text (custom settings)").leftIcon(R.drawable.ic_info).build();

    fg.text("Form Item: Button").leftIcon(R.drawable.ic_info, false).rightIcon(R.drawable.ic_chevron_right)
            .onClick(new TextViewFormItem.OnClickListener() {
                @Override
                public void onClick(TextViewFormItem item) {
                    Toast.makeText(MainActivity.this, "Form Item: Button Clicked", Toast.LENGTH_SHORT).show();
                }
            }).build();

    fg.space();

    fg.button("Form Item, Simple Button").onClick(new TextViewFormItem.OnClickListener() {
        @Override
        public void onClick(TextViewFormItem item) {
            Toast.makeText(MainActivity.this, "Form Item: Simple Button Clicked", Toast.LENGTH_SHORT).show();
        }
    }).build();

    fg.borderlessButton("Form Item, Borderless Button").onClick(new TextViewFormItem.OnClickListener() {
        @Override
        public void onClick(TextViewFormItem item) {
            Toast.makeText(MainActivity.this, "Form Item: Borderless Button Clicked", Toast.LENGTH_SHORT)
                    .show();
        }
    }).layoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT), Gravity.CENTER).build();

    fg.space();
    fg.line();

    fg.input("").hint("Form Item: Input").leftIcon(R.drawable.ic_info).inputBackground(0).build();

    fg.aSwitch("Form Item: Switch").onCheckChanged(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Toast.makeText(MainActivity.this, "Form Item: Switch changed", Toast.LENGTH_SHORT).show();
        }
    }).switchText("On", "Off").leftIcon(R.drawable.ic_info, false).build();
}

From source file:in.co.foodamigo.foodapp.module.common.view.widget.SlidingTabStripView.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  va 2s . 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.SERIF, Typeface.BOLD);
    textView.setTextColor(context.getResources().getColor(R.color.text_color_Categories));

    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, 0, padding, (padding / 2));

    return textView;
}

From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.TextTool.java

public void updateTypeface() {
    int style;//from  w  ww  .  j  a  v a 2s.  com
    if (mItalic) {
        style = Typeface.ITALIC;
    } else {
        style = Typeface.NORMAL;
    }

    if (mFont.equals("Sans Serif")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, style));
    } else if (mFont.equals("Serif")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.SERIF, style));
    } else if (mFont.equals("Monospace")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, style));
    }

    if (Build.VERSION.SDK_INT < 21) {
        mTextPaint.setTextSkewX(0.0f);
        if (mFont.equals("Monospace")) {
            mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL));
            if (style == Typeface.ITALIC) {
                mTextPaint.setTextSkewX(-0.25f);
            }
        }
    }
}

From source file:com.slushpupie.deskclock.DeskClock.java

/** Called when the activity is first created. */
@Override/*from   w  ww  . j  a v  a2 s .  c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    layout = (LinearLayout) findViewById(R.id.layout);
    display = (DisplayView) findViewById(R.id.display);
    registerForContextMenu(display);
    display.setOnTouchListener(this);
    display.setOnClickListener(this);

    fonts = new Typeface[17];
    fonts[0] = Typeface.DEFAULT_BOLD;
    fonts[1] = Typeface.SANS_SERIF;
    fonts[2] = Typeface.SERIF;
    fonts[3] = Typeface.MONOSPACE;
    fonts[4] = Typeface.createFromAsset(getAssets(), "fonts/Abduction2000.ttf");
    fonts[5] = Typeface.createFromAsset(getAssets(), "fonts/DSPoint.ttf");
    fonts[6] = Typeface.createFromAsset(getAssets(), "fonts/DSTerminal.ttf");
    fonts[7] = Typeface.createFromAsset(getAssets(), "fonts/DT104.ttf");
    fonts[8] = Typeface.createFromAsset(getAssets(), "fonts/Delusion.ttf");
    fonts[9] = Typeface.createFromAsset(getAssets(), "fonts/jd_scarabeo.ttf");
    fonts[10] = Typeface.createFromAsset(getAssets(), "fonts/stencilla.ttf");
    fonts[11] = Typeface.createFromAsset(getAssets(), "fonts/Digital2.ttf");
    fonts[12] = Typeface.createFromAsset(getAssets(), "fonts/DigitaldreamFat.ttf");
    fonts[13] = Typeface.createFromAsset(getAssets(), "fonts/DisplayDots.ttf");
    fonts[14] = Typeface.createFromAsset(getAssets(), "fonts/digi.otf");
    fonts[15] = Typeface.createFromAsset(getAssets(), "fonts/GentiumBinary.ttf");
    fonts[16] = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");

    loadPrefs();

    if (lastChangelog == null || !lastChangelog.equals(getString(R.string.app_version))) {
        DialogFragment df = ChangelogDialog.newInstance();
        df.show(getSupportFragmentManager(), "dialog");
    }

    configureDisplay();
    resizeClock();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
}

From source file:za.jamie.soundstage.widgets.PagerSlidingTabStrip.java

private void setTypefaceFromAttrs(String familyName, int typefaceIndex, int styleIndex) {
    Typeface tf = null;/*w w w. j a  v  a2  s.  c  o  m*/
    if (familyName != null) {
        tf = Typeface.create(familyName, styleIndex);
        if (tf != null) {
            setTypeface(tf);
            return;
        }
    }
    switch (typefaceIndex) {
    case SANS:
        tf = Typeface.SANS_SERIF;
        break;

    case SERIF:
        tf = Typeface.SERIF;
        break;

    case MONOSPACE:
        tf = Typeface.MONOSPACE;
        break;
    }
    setTypeface(tf, styleIndex);
}