Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

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

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:com.prey.activities.DeviceReadyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    setContentView(R.layout.device_ready);

    PreyLogger.d("onCreate of DeviceReadyActivity");

    final Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Bold.ttf");
    final Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(),
            "fonts/MagdaClean/magdacleanmono-regular.ttf");

    TextView textView3_1 = (TextView) findViewById(R.id.textView3_1);
    TextView textView3_2 = (TextView) findViewById(R.id.textView3_2);
    TextView textView4_1 = (TextView) findViewById(R.id.textView4_1);
    TextView textView4_2 = (TextView) findViewById(R.id.textView4_2);

    textView3_1.setTypeface(magdacleanmonoRegular);
    textView3_2.setTypeface(titilliumWebBold);
    textView4_1.setTypeface(magdacleanmonoRegular);
    textView4_2.setTypeface(titilliumWebBold);

    LinearLayout linearLayout1 = (LinearLayout) findViewById(R.id.linearLayout1);
    linearLayout1.setOnClickListener(new View.OnClickListener() {
        @Override//w  w  w .j a  v a  2  s .  c  o  m
        public void onClick(View v) {
            Intent intent = null;

            intent = new Intent(getApplication(), PanelWebActivity.class);

            startActivity(intent);
            finish();
        }
    });

    LinearLayout linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
    linearLayout2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = null;

            intent = new Intent(getApplication(), PreyConfigurationActivity.class);

            startActivity(intent);
            finish();
        }
    });

}

From source file:com.reddyetwo.hashmypass.app.TutorialIntroFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_tutorial_intro, container, false);
    mIcMasterKeyView = (ImageView) mRootView.findViewById(R.id.ic_master_key);
    mWebsiteTextView = (TextView) mRootView.findViewById(R.id.website_text);
    mWebsitePasswordView = (TextView) mRootView.findViewById(R.id.website_password);
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), Constants.FONT_MONOSPACE);
    mWebsitePasswordView.setTypeface(tf);

    mRandom = new Random();

    return mRootView;
}

From source file:geotag.example.sbickt.BicksActivity.java

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

    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/LiteraEF-Medium.otf");
    editTextBicks = (EditText) findViewById(R.id.edit_text_bicks);
    buttonBicks = (ImageButton) findViewById(R.id.button_bicks);
    radioGroupCategory = (RadioGroup) findViewById(R.id.radio_group_category);
    radioButtonPrivate = (RadioButton) findViewById(R.id.radio_category_private);
    radioButtonFriends = (RadioButton) findViewById(R.id.radio_category_friends);
    radioButtonPublic = (RadioButton) findViewById(R.id.radio_category_public);

    editTextBicks.setTypeface(tf);//from w  w  w.  j a v  a 2s . co m
    editTextBicks.setEnabled(false);
    buttonBicks.setEnabled(false);
    radioButtonPrivate.setTag("private");
    radioButtonFriends.setTag("protected");
    radioButtonPublic.setTag("public");

    radioGroupCategory.setOnCheckedChangeListener(radioGroupCategoryOnCheckedChangeListener);
    buttonBicks.setOnClickListener(buttonBicksOnClickListener);

    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 10, locationListener);

}

From source file:com.taobao.weex.utils.TypefaceUtil.java

private static void loadFromAsset(FontDO fontDo, String path) {
    try {//from  w w w. j a  v  a  2 s. c  o m
        Typeface typeface = Typeface.createFromAsset(WXEnvironment.getApplication().getAssets(), path);
        if (typeface != null) {
            if (WXEnvironment.isApkDebugable()) {
                WXLogUtils.d(TAG, "load asset file success");
            }
            fontDo.setState(FontDO.STATE_SUCCESS);
            fontDo.setTypeface(typeface);
        } else {
            WXLogUtils.e(TAG, "Font asset file not found " + fontDo.getUrl());
        }
    } catch (Exception e) {
        WXLogUtils.e(TAG, e.toString());
    }
}

From source file:org.gluu.super_gluu.app.fragments.LicenseFragment.LicenseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.license_fragment, container, false);
    WebView licenseWebView = (WebView) view.findViewById(R.id.license_webView);
    licenseWebView.loadDataWithBaseURL(null, readLicenseTxt(), "text/html", "UTF-8", null);
    //        licenseTextView.setMovementMethod(new ScrollingMovementMethod());

    Button aceptButton = (Button) view.findViewById(R.id.accept_button);
    LinearLayout action_left_button = (LinearLayout) view.findViewById(R.id.action_left_button);
    action_left_button.setOnClickListener(new View.OnClickListener() {
        @Override/*ww w.  j a  va  2s . co m*/
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    aceptButton.setOnClickListener(this);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) licenseWebView.getLayoutParams();
    if (!isForFirstLoading) {
        aceptButton.setVisibility(View.GONE);
        action_left_button.setVisibility(View.VISIBLE);
        params.weight = 0.25f;
    } else {
        action_left_button.setVisibility(View.GONE);
        params.weight = 0.98f;
    }
    licenseWebView.setLayoutParams(params);
    //Setup fonts
    Typeface face = Typeface.createFromAsset(getActivity().getAssets(), "ProximaNova-Regular.otf");
    aceptButton.setTypeface(face);

    return view;
}

From source file:org.cicadasong.samples.nextbuses.NextBuses.java

private void createFontPainters() {
    Typeface fontMetawatch11px = Typeface.createFromAsset(getAssets(), "fonts/metawatch_16pt_11pxl_proto1.ttf");
    metawatch11px = new Paint();
    metawatch11px.setTypeface(fontMetawatch11px);
    metawatch11px.setTextSize(16);/*from   w ww .  j a va2 s  . c  o m*/

    Typeface fontMetawatch7px = Typeface.createFromAsset(getAssets(),
            "fonts/metawatch_8pt_7pxl_CAPS_proto1.ttf");
    metawatch7px = new Paint();
    metawatch7px.setTypeface(fontMetawatch7px);
    metawatch7px.setTextSize(8);

    Typeface fontMetawatch5px = Typeface.createFromAsset(getAssets(),
            "fonts/metawatch_8pt_5pxl_CAPS_proto1.ttf");
    metawatch5px = new Paint();
    metawatch5px.setTypeface(fontMetawatch5px);
    metawatch5px.setTextSize(8);

    default10pt = new Paint();
    default10pt.setTextSize(10);
}

From source file:com.ubuntuone.android.files.activity.TutorialActivity.java

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

    mAdapter = new MyAdapter(getSupportFragmentManager());

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);//from  w ww.  ja  va 2  s .  c  o  m
    mPager.setOnPageChangeListener(this);

    mPageIndicator = (PageIndicator) findViewById(R.id.indicator);
    mPageIndicator.setDotCount(maxPages);
    mPageIndicator.setDotSpacing(6);
    mPageIndicator.setDotDrawable(getResources().getDrawable(R.drawable.pager_dot));

    signUpNowButton = (Button) findViewById(R.id.sign_up_now);

    final Typeface ubuntuB = Typeface.createFromAsset(getAssets(), "Ubuntu-B.ttf");
    signUpNowButton.setTypeface(ubuntuB);

    signUpNowButton.setOnClickListener(this);
}

From source file:com.commonslab.commonslab.Fragments.UploadToCommonsFragment.java

private void setFonts() {
    Typeface type = Typeface.createFromAsset(getActivity().getAssets(), "fonts/open_sans/OpenSans-Regular.ttf");
    uploadTitleTextView.setTypeface(type);
    uploadDescriptionTextView.setTypeface(type);
    uploadCommentTextView.setTypeface(type);

}

From source file:com.reddyetwo.hashmypass.app.tutorial.TutorialIntroFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_tutorial_intro, container, false);
    mIcMasterKeyView = (ImageView) rootView.findViewById(R.id.ic_master_key);
    mWebsiteTextView = (TextView) rootView.findViewById(R.id.website_text);
    mWebsitePasswordView = (TextView) rootView.findViewById(R.id.website_password);
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), Constants.FONT_MONOSPACE);
    mWebsitePasswordView.setTypeface(tf);

    mRandom = new Random();

    createAnimation();// w  w  w  .ja va 2s.  c  o  m

    return rootView;
}

From source file:com.awt.supark.EditCar.java

@Nullable
@Override//from  w ww  .j a  va2s .c  o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.edit_car, container, false);

    addCarButton = (Button) view.findViewById(R.id.DoneButton);
    deleteButton = (Button) view.findViewById(R.id.DeleteButton);
    cancelButton = (Button) view.findViewById(R.id.cancelButton);
    carName = (EditText) view.findViewById(R.id.carName);
    carLicense = (EditText) view.findViewById(R.id.carLicense);
    txtCity = (TextView) view.findViewById(R.id.city);
    txtNum = (TextView) view.findViewById(R.id.number);
    radioNewSrb = (RadioButton) view.findViewById(R.id.radioNewSrb);
    radioGeneric = (RadioButton) view.findViewById(R.id.radioGeneric);
    radioLicenseGroup = (RadioGroup) view.findViewById(R.id.radioLicenseGroup);
    licensePlate = (LinearLayout) view.findViewById(R.id.licensePlate);
    licenseNum = "";
    context = getContext();

    // Setting the custom font
    Typeface licenseFont = Typeface.createFromAsset(getContext().getAssets(), "fonts/LicensePlate.ttf");
    txtCity.setTypeface(licenseFont);
    txtNum.setTypeface(licenseFont);

    db = SQLiteDatabase.openDatabase(getContext().getFilesDir().getPath() + "/carDB.db", null,
            SQLiteDatabase.CREATE_IF_NECESSARY);
    final Bundle b = getArguments();

    if (b.getInt("editid") != -1) {
        editid = b.getInt("editid");
        Cursor d = db.rawQuery("SELECT * FROM cars WHERE car_id = " + editid, null);
        d.moveToFirst();

        carName.setText(d.getString(d.getColumnIndex("car_name")));
        licenseNum = d.getString(d.getColumnIndex("car_license"));
        carLicense.setText(licenseNum);

        if (d.getInt(d.getColumnIndex("isgeneric")) == 0) {
            radioNewSrb.setChecked(true);
            radioGeneric.setChecked(false);
            radioListener();
        } else {
            radioGeneric.setChecked(true);
            radioNewSrb.setChecked(false);
            radioListener();
        }

        deleteButton.setVisibility(View.VISIBLE);
        if (isCarParked(editid)) {
            deleteButton.setEnabled(false);
        }
        TextView text = (TextView) view.findViewById(R.id.text1);
        text.setText(context.getResources().getString(R.string.edit_car));
        d.close();
    } else {
        radioNewSrb.setChecked(true);
        radioListener();
    }

    addCarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (editid == -1) {
                addCar(v);
            } else {
                editCar(v);
            }
        }
    });

    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDeleteQuestionDialog("", getResources().getString(R.string.are_you_sure), v);
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ((MainActivity) context).openCarFragment(null, true);
        }
    });

    // Filters the emojis and other unwanted characters
    filter = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            for (int i = start; i < end; i++) {
                if (!Character.isLetterOrDigit(source.charAt(i))) {
                    return "";
                }
            }
            return null;
        }
    };
    carName.setFilters(new InputFilter[] { filter });
    //carLicense.setFilters(new InputFilter[] { filter });

    // License number filler
    carLicense.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            licenseNum = charSequence.toString();
            updateLicensePlate(charSequence);
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

    radioLicenseGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            radioListener();
        }
    });

    return view;
}