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.gh4a.IssueLabelListActivity.java

private void unselectLabel(TextView tvLabel, View viewColor, String color) {
    final Typeface condensed = getApplicationContext().condensed;
    tvLabel.setTag(color);//from w  ww.  ja  va2s.c o m
    tvLabel.setBackgroundColor(0);
    if (Gh4Application.THEME == R.style.LightTheme) {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light));
    } else {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark));
    }
    tvLabel.setTypeface(condensed);
    viewColor.setBackgroundColor(Color.parseColor("#" + color));
}

From source file:com.example.drugsformarinemammals.Dose_Information.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 ww  .j a  v a 2 s  .co  m*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText("Synchronization");
    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:mobile.tiis.appv2.LoginActivity.java

@Override
protected void onCreate(Bundle starter) {
    super.onCreate(starter);
    setContentView(R.layout.login_activity);

    // We load the KeyStore
    try {//from  w w w.  j  a va2 s  .  c om
        /// We initialize a default Keystore
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        // We initialize a new SSLSocketFacrory
        MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
        // We set that all host names are allowed in the socket factory
        socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        // We set the SSL Factory
        client.setSSLSocketFactory(socketFactory);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (KeyManagementException e) {
        e.printStackTrace();
    }

    client.setTimeout(DEFAULT_TIMEOUT);
    client.setMaxConnections(20);

    app = (BackboneApplication) getApplication();
    databaseHandler = app.getDatabaseInstance();
    if (checkPlayServices()) {
        gcm = GoogleCloudMessaging.getInstance(this);
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        if (isInternetAvailable()) {
            /**
             * registering the appv2 to Google Cloud Messaging
             */
            regId = getRegistrationId(getApplicationContext());
            Log.d(TAG, "regID = " + regId);
            if (regId.equals("")) {
                registerInBackground();
            }
        }
    } else {
        Log.i(TAG, "No valid Google Play Services APK found.");
    }

    //DatabaseHandler.getDBFile(this);
    //Delete vaccinationQueueRows that are not from today
    TextView titleText = (TextView) findViewById(R.id.login_screen_title);
    TextView ministryName = (TextView) findViewById(R.id.ministry_name);
    ministryName.setTypeface(BackboneActivity.Rosario_Regular);
    titleText.setTypeface(BackboneActivity.Rosario_Regular);
    //        getActionBar().setBackgroundDrawable(new ColorDrawable(this.getResources().getColor(R.color.light_blue_600)));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }

    String dateNow = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
    databaseHandler.deleteVaccinationQueueEntriesOfOtherDays(dateNow);

    app.LAST_FRAGMENT = "mobile.tiis.appv2.fragments.HomeFragment";
    app.LAST_FRAGMENT_TITLE = getString(R.string.home);

    //Starting the repeating synchronisation procedure that happens every 5 minutes
    login_preferences = getSharedPreferences(LOGINPREFERENCE, Context.MODE_PRIVATE);

    if (getIntent().hasExtra(BackboneActivity.LANGUAGELOGIN)) {
        languagePosition = getIntent().getIntExtra(BackboneActivity.LANGUAGELOGIN, 0);
        Log.d(TAGG, "Language Position before select = " + languagePosition + "");
    }

    progressDialog = new ProgressDialog(this, 0);
    language = (MaterialSpinner) findViewById(R.id.lang_spinner);
    listLanguage = new ArrayList<String>();
    listLanguage.add("Swahili");
    listLanguage.add("English");

    //Get username and password
    usernameEditText = (MaterialEditText) findViewById(R.id.username);
    usernameEditText.setFocusableInTouchMode(true);
    passwordEditText = (MaterialEditText) findViewById(R.id.password);
    passwordEditText.setFocusableInTouchMode(true);

    //Listen for a Login button click
    loginButton = (Button) findViewById(R.id.login_btn);
    SingleTextViewAdapter adapter = new SingleTextViewAdapter(this, R.layout.single_text_spinner_item_drop_down,
            listLanguage);
    language.setAdapter(adapter);

    language.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i) {
            case 0:
                languagePosition = 0;
                setLocale("sw");
                Log.d(TAGG, "selected position is " + i + " I put 0");
                break;
            case 1:
                languagePosition = 1;
                setLocale("en");
                Log.d(TAGG, "selected position is " + i + " I put 1");
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    loginButton.setOnClickListener(this);
    getSavedConfigurations();
}

From source file:com.guerinet.materialtabs.TabLayout.java

/**
 * Sets up the title {@link TextView} as per the material guidelines
 *
 * @param textView The TextView//w w  w.  j  a  va 2s .c  om
 */
private void prepareTextView(TextView textView) {
    //Keep it to 1 line or the selectors won't work
    textView.setSingleLine();

    //Set the text to all caps if we are in 14+
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        textView.setAllCaps(true);
    }

    //Tabs are bold
    textView.setTypeface(Typeface.DEFAULT_BOLD);
}

From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java

private void showHelpView(LayoutInflater layoutInflater) {
    if (Util.gethelpboolean(this, Constant.HELP_PREF_PROFILE)) {
        Util.storehelpboolean(this, Constant.HELP_PREF_PROFILE, false);
        helpView = layoutInflater.inflate(R.layout.profile_help, null, false);
        helpLl = (RelativeLayout) helpView.findViewById(R.id.profile_help_ll);
        helpLl.setY(bottom);/*from w  ww. j ava 2s.c  o m*/
        TextView arrowTv = (TextView) helpView.findViewById(R.id.profile_help_arrow);
        arrowTv.setTypeface(Util.getArrowFont(this));
        int x = getWindowManager().getDefaultDisplay().getWidth() / 3 - right + 30;
        LinearLayout linearLayout = (LinearLayout) helpView.findViewById(R.id.layoutStepInstruction);
        linearLayout.setX(x);

        TextView arrowSteps = (TextView) helpView.findViewById(R.id.txtStepsArrow);
        arrowSteps.setTypeface(Util.getArrowFont(this));

        TextView txtCoatch = ((TextView) helpView.findViewById(R.id.txtCoachMarks));
        txtCoatch.setTypeface(Util.getFontSegoe(this));

        /* if ((getResources().getConfiguration().screenLayout &
            Configuration.SCREENLAYOUT_SIZE_MASK) ==
            Configuration.SCREENLAYOUT_SIZE_LARGE|| Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_NORMAL||Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_XLARGE||Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_UNDEFINED) {
        txtCoatch.setTypeface(Util.getFontSegoe(this));
        txtCoatch.setVisibility(View.VISIBLE);
                
         }else {
        txtCoatch.setVisibility(View.GONE);
         }*/
        int h = getWindowManager().getDefaultDisplay().getHeight();
        if (getWindowManager().getDefaultDisplay().getHeight() <= 800) {
            txtCoatch.setVisibility(View.GONE);
        }

        ((TextView) helpView.findViewById(R.id.profile_tap_tv)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_1)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_2)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_3)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.tap_tv_dismiss)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.txtCoachMarks)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.txtSteps)).setTypeface(Util.getFontSegoe(this));

        // arrowTv.setX((left+right) / 2);

        TextView txtHelp = ((TextView) helpView.findViewById(R.id.profile_help_tv));
        txtHelp.setTypeface(Util.getFontSegoe(this));
        //txtHelp.setY(bottom);;

        //((TextView) helpView.findViewById(R.id.help_tv)).setX((left+right) / 4);
        RelativeLayout helpLayout = ((RelativeLayout) helpView.findViewById(R.id.profile_help_rl));
        helpLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                frameLayout.removeView(helpView);
            }
        });
        frameLayout.addView(helpView);
    }
}

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

public TextView createInformationTextView() {
    TextView information_textview = new TextView(this);
    information_textview.setTextColor(Color.BLACK);
    information_textview.setTextSize(16);
    information_textview.setTypeface(Typeface.SANS_SERIF);
    return information_textview;
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void boldifyText(EditorControl tag, TextView editText, int textMode) {
    if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.NORMAL));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.ITALIC));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC));
    } else {/*  www .ja v  a  2 s . c  o  m*/
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD));
    }
    editText.setTag(tag);
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void italicizeText(EditorControl tag, TextView editText, int textMode) {

    if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.NORMAL));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC));
    } else {/*from  w ww.j a  va2 s. co  m*/
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.ITALIC));
    }
    editText.setTag(tag);
}

From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java

public void showTrialDialog(final boolean expired, int numDaysRemaining) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle(R.string.app_name);
    builder.setCancelable(false);/*from   ww  w .  ja  v a  2  s.  com*/

    View view = this.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null);
    TextView trialExpiredText = (TextView) view.findViewById(R.id.trial_message);
    TextView trialDaysRemaining = (TextView) view.findViewById(R.id.trial_days_remaining);
    TextView trialDaysCaps = (TextView) view.findViewById(R.id.days_caps);

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

    trialDaysRemaining.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));

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

    if (expired) {
        trialDaysRemaining.setText(R.string.expired);
        trialExpiredText.setText(R.string.trial_expired);
        trialDaysRemaining.setTextColor(0xFFFF8800);
        trialDaysCaps.setVisibility(View.GONE);
        trialDaysRemaining.setTextSize(36);
        trialDaysRemaining.setPaintFlags(
                trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    } else {
        trialExpiredText.setText(R.string.trial_running);
        trialDaysRemaining.setText("" + numDaysRemaining);
        trialDaysCaps.setVisibility(View.VISIBLE);
        trialDaysRemaining.setTextColor(0xFF0099CC);
        trialDaysRemaining.setPaintFlags(trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG
                | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
    }

    builder.setView(view);
    builder.setPositiveButton(R.string.upgrade, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            showUpgradeFragmentWithPromo();

        }

    });

    builder.setNegativeButton(R.string.later, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (expired) {
                finish();
            } else {
                launchMainActivity();
            }

        }

    });

    builder.create().show();
}

From source file:com.ved.musicmapapp.LoginAcitivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_login_facebook);
    checkGooglePlayService();//from   w ww  .j av  a2 s .  co  m

    isMusics = false;
    isMovies = false;
    isBooks = false;
    isGames = false;
    isMe = false;

    prefs = getSharedPreferences("MUSIC_MAP", MODE_PRIVATE);
    edt = prefs.edit();

    btnLogin = findViewById(R.id.btn_login);
    TextView discover_heading = (TextView) findViewById(R.id.discover_heading);
    Typeface tf = Typeface.createFromAsset(getAssets(), "open_sans_regular.ttf");
    discover_heading.setTypeface(tf);

    btnLogin.setOnClickListener(this);

    pd = new ProgressDialog(this);
    pd.setMessage("Logging...");
    pd.setCancelable(false);

    if (getIntent().getBooleanExtra("LOGOUT", false)) {
        onClickLogout();
    }

    initFacebook(savedInstanceState);

    try {
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.i("PXR", com.ved.musicmapapp.utils.Base64.encodeBytes(md.digest()));
        }
    } catch (NameNotFoundException e) {
    } catch (NoSuchAlgorithmException e) {
    }

    updateView();
}