Example usage for android.graphics Typeface SANS_SERIF

List of usage examples for android.graphics Typeface SANS_SERIF

Introduction

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

Prototype

Typeface SANS_SERIF

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

Click Source Link

Document

The NORMAL style of the default sans serif typeface.

Usage

From source file:com.startup.manager.lolipop.component.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 a2 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.SANS_SERIF);
    textView.setTextColor(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);
    }

    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.dialer.calllog.PhoneCallDetailsHelper.java

/** Fills the call details views with content. */
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
    // Display up to a given number of icons.
    views.callTypeIcons.clear();//from  www  . j ava  2 s  .com
    int count = details.callTypes.length;
    boolean isVoicemail = false;
    for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) {
        views.callTypeIcons.add(details.callTypes[index]);
        if (index == 0) {
            isVoicemail = details.callTypes[index] == Calls.VOICEMAIL_TYPE;
        }
    }

    // Show the video icon if the call had video enabled.
    views.callTypeIcons.setShowVideo((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO);
    views.callTypeIcons.requestLayout();
    views.callTypeIcons.setVisibility(View.VISIBLE);

    // Show the total call count only if there are more than the maximum number of icons.
    final Integer callCount;
    if (count > MAX_CALL_TYPE_ICONS) {
        callCount = count;
    } else {
        callCount = null;
    }

    // Set the call count, location, date and if voicemail, set the duration.
    setDetailText(views, callCount, details);

    // Set the account label if it exists.
    String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);
    if (!TextUtils.isEmpty(details.viaNumber)) {
        if (!TextUtils.isEmpty(accountLabel)) {
            accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, accountLabel,
                    details.viaNumber);
        } else {
            accountLabel = mResources.getString(R.string.call_log_via_number, details.viaNumber);
        }
    }
    if (!TextUtils.isEmpty(accountLabel)) {
        views.callAccountLabel.setVisibility(View.VISIBLE);
        views.callAccountLabel.setText(accountLabel);
        int color = mCallLogCache.getAccountColor(details.accountHandle);
        if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
            int defaultColor = R.color.dialtacts_secondary_text_color;
            views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor));
        } else {
            views.callAccountLabel.setTextColor(color);
        }
    } else {
        views.callAccountLabel.setVisibility(View.GONE);
    }

    final CharSequence nameText;
    final CharSequence displayNumber = details.displayNumber;
    if (TextUtils.isEmpty(details.getPreferredName())) {
        nameText = displayNumber;
        // We have a real phone number as "nameView" so make it always LTR
        views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
    } else {
        nameText = details.getPreferredName();
    }

    views.nameView.setText(nameText);

    if (isVoicemail) {
        views.voicemailTranscriptionView
                .setText(TextUtils.isEmpty(details.transcription) ? null : details.transcription);
    }

    // Bold if not read
    Typeface typeface = details.isRead ? Typeface.SANS_SERIF : Typeface.DEFAULT_BOLD;
    views.nameView.setTypeface(typeface);
    views.voicemailTranscriptionView.setTypeface(typeface);
    views.callLocationAndDate.setTypeface(typeface);
    views.callLocationAndDate.setTextColor(ContextCompat.getColor(mContext,
            details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color));
}

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);//from   www. j  ava  2s.c o 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: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)}./*  ww w  . j  av  a 2s .c  o  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;
}

From source file:com.themitpost.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 w  w  .j ava2  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.SANS_SERIF);
    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(false);

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

    return textView;
}

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

public void updateTypeface() {
    int style;// w w  w.ja  va2 s .co m
    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.kmagic.solitaire.DrawMaster.java

/**
 * Get paint for text use/*from  ww w  .  j  a v a 2  s  .com*/
 * @return red paint object
 */
public static Paint getTextPaint(final float fontSize, final Paint.Align align) {
    Paint paint = getPaint();
    paint.setTextSize(fontSize);
    paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    paint.setTextAlign(align);
    return (paint);
}

From source file:com.google.android.apps.iosched.util.UIUtils.java

public static void updateTimeAndLivestreamBlockUI(final Context context, long blockStart, long blockEnd,
        boolean hasLivestream, View backgroundView, TextView titleView, TextView subtitleView,
        CharSequence subtitle) {//from w  w w  . jav  a  2s  .c o m
    long currentTimeMillis = getCurrentTime(context);

    boolean past = (currentTimeMillis > blockEnd && currentTimeMillis < CONFERENCE_END_MILLIS);
    boolean present = (blockStart <= currentTimeMillis && currentTimeMillis <= blockEnd);

    final Resources res = context.getResources();
    if (backgroundView != null) {
        backgroundView.setBackgroundColor(past ? res.getColor(R.color.past_background_color) : 0);
    }

    if (titleView != null) {
        titleView.setTypeface(Typeface.SANS_SERIF, past ? Typeface.NORMAL : Typeface.BOLD);
    }

    if (subtitleView != null) {
        boolean empty = true;
        SpannableStringBuilder sb = new SpannableStringBuilder(); // TODO: recycle
        if (subtitle != null) {
            sb.append(subtitle);
            empty = false;
        }

        if (present) {
            if (sNowPlayingText == null) {
                sNowPlayingText = Html.fromHtml(context.getString(R.string.now_playing_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sNowPlayingText);

            if (hasLivestream) {
                if (sLivestreamNowText == null) {
                    sLivestreamNowText = Html
                            .fromHtml("&nbsp;&nbsp;" + context.getString(R.string.live_now_badge));
                }
                sb.append(sLivestreamNowText);
            }
        } else if (hasLivestream) {
            if (sLivestreamAvailableText == null) {
                sLivestreamAvailableText = Html.fromHtml(context.getString(R.string.live_available_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sLivestreamAvailableText);
        }

        subtitleView.setText(sb);
    }
}

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

/** Called when the activity is first created. */
@Override//from  ww w .  j a  v a 2s.c om
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:gov.wa.wsdot.android.wsdot.ui.home.HomeActivity.java

/**
 * Attempts to check if there is a new version of the notification list.
 * Alerts users with a tap target view if there is.
 *//*ww w. j av  a  2 s  .  c om*/
private void tryDisplayNotificationTipView() {

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    int topicVersion = settings.getInt(getString(R.string.firebase_notification_topics_version), 0);
    int newTopicVersion = settings.getInt(getString(R.string.new_firebase_notification_topics_version), 0);

    String title = settings.getString(getString(R.string.firebase_notification_title),
            "New Notifications Available");
    String description = settings.getString(getString(R.string.firebase_notification_description), "");

    AccessibilityManager am = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);

    Boolean accessibilityEnabled = false;
    if (am != null) {
        accessibilityEnabled = am.isEnabled();
    }

    if ((topicVersion < newTopicVersion) && !accessibilityEnabled) {

        try {
            TapTargetView.showFor(this,
                    TapTarget.forToolbarMenuItem(mToolbar, R.id.menu_notifications, title, description)
                            // All options below are optional
                            .outerCircleColor(R.color.primary_default) // Specify a color for the outer circle
                            .titleTextSize(20) // Specify the size (in sp) of the title text
                            .titleTextColor(R.color.white) // Specify the color of the title text
                            .descriptionTextSize(15) // Specify the size (in sp) of the description text
                            .textColor(R.color.white) // Specify a color for both the title and description text
                            .textTypeface(Typeface.SANS_SERIF) // Specify a typeface for the text
                            .dimColor(R.color.black) // If set, will dim behind the view with 30% opacity of the given color
                            .drawShadow(true) // Whether to draw a drop shadow or not
                            .cancelable(true) // Whether tapping outside the outer circle dismisses the view
                            .tintTarget(true) // Whether to tint the target view's color
                            .transparentTarget(true) // Specify whether the target is transparent (displays the content underneath)
                            .targetRadius(40), // Specify the target radius (in dp)
                    new TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels
                        @Override
                        public void onTargetClick(TapTargetView view) {
                            super.onTargetClick(view);
                            startActivity(new Intent(HomeActivity.this, NotificationsActivity.class));
                        }
                    });
        } catch (NullPointerException | IllegalArgumentException e) {
            Log.e(TAG, "Exception while trying to show tip view");
            Log.e(TAG, e.getMessage());
        }
    }
    settings.edit().putInt(getString(R.string.firebase_notification_topics_version), newTopicVersion).apply();
}