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.support.android.designlibdemo.EditContactActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit);

    Intent intent = getIntent();/*from w  w  w. j  a  va2 s .com*/
    //contact= getIntent().getParcelableExtra("ContactTag");
    cheeseName = intent.getStringExtra(EXTRA_NAME);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    Typeface fontAwesomeFont = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf");

    Button CallTel1 = (Button) findViewById(R.id.CallTel1);

    Button CallTel2 = (Button) findViewById(R.id.CallTel2);

    Button SendMail = (Button) findViewById(R.id.SendMail1);

    Button LocateSociete1 = (Button) findViewById(R.id.LocateSociete1);

    Button LocateSite1 = (Button) findViewById(R.id.LocateSite1);

    Button LocateAdres1 = (Button) findViewById(R.id.LocateAdres1);

    CallTel1.setTypeface(fontAwesomeFont);

    CallTel2.setTypeface(fontAwesomeFont);
    SendMail.setTypeface(fontAwesomeFont);

    LocateAdres1.setTypeface(fontAwesomeFont);

    LocateSite1.setTypeface(fontAwesomeFont);

    LocateSociete1.setTypeface(fontAwesomeFont);

    _name = ((EditText) findViewById(R.id.Nom));

    _prenom = ((EditText) findViewById(R.id.Prenom));

    _phone_number = ((EditText) findViewById(R.id.Tel1));

    _email = ((EditText) findViewById(R.id.Mail1));

    _fixe = ((EditText) findViewById(R.id.Tel2));

    _societe = ((EditText) findViewById(R.id.Societe1));

    _adresse = ((EditText) findViewById(R.id.Adres1));

    _profile = ((EditText) findViewById(R.id.Position));

    _site = ((EditText) findViewById(R.id.Site1));

    _skype = ((EditText) findViewById(R.id.Skype1));

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Log.e("Search Query: ", "  hellooo " + cheeseName);

    handleIntent(getIntent());
    Common.setNfcAdapter(NfcAdapter.getDefaultAdapter(this));
    reader = Common.checkForTagAndCreateReader(this);
    if (cheeseName.compareTo("Editer") == 0)
        readTag(0);
}

From source file:com.jwork.dhammapada.ContentFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    tfPali = Typeface.createFromAsset(getActivity().getAssets(), "fonts/arlrdbd.ttf");

    verseIndex = getArguments().getInt(KEY_VERSE_INDEX);
    chapter = (Chapter) getArguments().getSerializable(KEY_CHAPTER_INDEX);
    searchQuery = getArguments().getString(KEY_SEARCH_QUERY);

    Bundle bundle = new Bundle();
    bundle.putInt(KEY_VERSE_INDEX, verseIndex);
    getLoaderManager().initLoader(LOADER_VERSE, bundle, this);
}

From source file:jhe.lin.boo.profile.PagerActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*  w  ww  .j a  v  a 2 s .co m*/
    WH.getDisplayMetrics(this);

    audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

    pager_bar = (LinearLayout) findViewById(R.id.pager_bar);
    LayoutParams ll = (LayoutParams) pager_bar.getLayoutParams();
    ll.topMargin = WH.getHeightPercent(70);
    pager_bar.setLayoutParams(ll);

    title = (TextView) findViewById(R.id.title);
    ll = (LayoutParams) title.getLayoutParams();
    ll.topMargin = WH.getHeightPercent(10);
    title.setLayoutParams(ll);

    pager = (ViewPager) findViewById(R.id.pager);
    title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/w1.otf"));
    initPages_bar();
    pager.setPageTransformer(true, new ZoomOutPageTransformer());
    PagerAdapter adapter = new MyPagerAdapter();
    pager.setAdapter(adapter);
    pager.setCurrentItem(firstPage);
    pager.setOnPageChangeListener(new OnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub
            for (int i = 0; i < item.length; i++) {
                CircleView cv = (CircleView) pager_bar.getChildAt(i);
                cv.setColor(Color.parseColor(DEFAULT));
            }
            CircleView cv = (CircleView) pager_bar.getChildAt(pager.getCurrentItem());
            cv.setColor(Color.parseColor(SELECTED));
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageSelected(int arg0) {
            // TODO Auto-generated method stub

        }
    });
    //Necessary or the pager will only have one extra page to show
    // make this at least however many pages you can see
    pager.setOffscreenPageLimit(adapter.getCount());
    //A little space between pages
    pager.setPageMargin(15);

    //If hardware acceleration is enabled, you should also remove
    // clipping on the pager for its children.
    pager.setClipChildren(false);

}

From source file:com.example.oblivion.swippedui.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btnNext = (ImageView) findViewById(R.id.a);
    btnPrev = (ImageView) findViewById(R.id.b);
    lblHeaderUserInApp = (TextView) findViewById(R.id.lblHeaderUserInApp);
    lblHeader1InApp = (TextView) findViewById(R.id.lblHeader1InApp);
    lblHeaderAgentInApp = (TextView) findViewById(R.id.lblHeaderAgentInApp);
    lblHeader2InApp = (TextView) findViewById(R.id.lblHeader2InApp);
    lblHeaderOutletInApp = (TextView) findViewById(R.id.lblHeaderOutletInApp);
    lblHeader3InApp = (TextView) findViewById(R.id.lblHeader3InApp);

    Typeface externalFont = Typeface.createFromAsset(getAssets(), "kalpurush.ttf");

    lblHeaderUserInApp.setTypeface(externalFont);
    //  lblHeader1InApp.setTypeface(externalFont);
    lblHeaderAgentInApp.setTypeface(externalFont);
    //  lblHeader2InApp.setTypeface(externalFont);
    lblHeaderOutletInApp.setTypeface(externalFont);
    //  lblHeader3InApp.setTypeface(externalFont);
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.//w w  w. j a va  2 s  . co  m
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.

            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    actionBar.hide();
    btnNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1);
        }
    });
    btnPrev.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
        }
    });
}

From source file:io.coldstart.android.TrapDetailListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Trap trap = listOfTraps.get(position);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    convertView = inflater.inflate(R.layout.trap_detail_list_item, null);

    String TrapDetails = "";

    /*try/*from  w ww  .j  a  v  a 2  s.c o m*/
    {
    JSONArray TrapJSON = new JSONArray(trap.trap);
            
    int trapsCount = TrapJSON.length();
            
    for(int i = 0; i < trapsCount; i++)
    {
        String tmpPayload = TrapJSON.getString(i);
            
        if(!tmpPayload.equals(""))
        {
            TrapDetails += tmpPayload + "\n\n";
        }
    }
    }
    catch (JSONException e)
    {
    TrapDetails = "Trap details failed to parse";
    }
            
            
    ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(TrapDetails);*/
    String trapDescription = "";
    try {
        trapDescription = trap.getPayloadAsString();
    } catch (Exception e) {
        trapDescription = "Unable to decode trap";
    }

    ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(trapDescription);

    ((TextView) convertView.findViewById(R.id.TrapDate))
            .setTypeface(Typeface.createFromAsset((context).getAssets(), "fonts/MavenPro-Regular.ttf"));
    ((TextView) convertView.findViewById(R.id.TrapDate)).setText(trap.date);

    if (trapOnClick != null) {
        convertView.setTag(position);
        convertView.setOnClickListener((OnClickListener) trapOnClick);
    }

    return convertView;
}

From source file:edu.mecc.race2ged.helpers.Utils.java

/**
 * Sets the font of a view to Roboto-Light
 * @param context The context of the activity.
 * @param view The view that will use Roboto-Light
 * @param style The style for the font face. i.e Typeface.BOLD
 *///from  www . j a v a2s.c o  m
public static void setRobotoThin(Context context, View view, int style) {
    if (sRobotoThin == null) {
        sRobotoThin = Typeface.createFromAsset(context.getAssets(), "Roboto-Light.ttf");
    }
    setFont(view, sRobotoThin, style);
}

From source file:cl.smartcities.isci.transportinspector.adapters.dialogAdapters.BusSelectionAdapter.java

public View getView(final int position, View convertView, final ViewGroup parent) {
    final ViewHolder holder;
    /* set view */
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.bus_selection_dialog_bus_row, parent, false);
        holder = new ViewHolder();

        /* initialize holder */
        holder.busRoute = (TextView) convertView.findViewById(R.id.bus_route);
        holder.licensePlate1 = (TextView) convertView.findViewById(R.id.license_plate_1);
        holder.licencePlate2 = (TextView) convertView.findViewById(R.id.license_plate_2);
        holder.doNotKnowIcon = (TextView) convertView.findViewById(R.id.do_not_know_icon);
        holder.doNotKnow = (LinearLayout) convertView.findViewById(R.id.do_not_know_layout);
        holder.busImage = (ImageView) convertView.findViewById(R.id.bus_image);
        holder.dropDownButton = (ImageButton) convertView.findViewById(R.id.button);
        holder.platesLayout = convertView.findViewById(R.id.bus_options);
        holder.headerLayout = convertView.findViewById(R.id.route_info);

        /* get and set typefaces */
        Typeface iconFont = Typeface.createFromAsset(this.getContext().getAssets(),
                this.getContext().getString(R.string.icon_font));
        Typeface robotoBold = Typeface.createFromAsset(this.getContext().getAssets(),
                this.getContext().getString(R.string.roboto_bold_font));
        holder.doNotKnowIcon.setTypeface(iconFont);
        holder.setHolderTypefaceBold(robotoBold);
        holder.position = position;//w w w  .ja  v  a 2  s.  c om

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
        if (activeHolder != null && holder.position == activeHolder.position) {
            activeHolder = null;
        }
    }

    holder.platesLayout.setVisibility(View.GONE);

    setUpNormalRow(holder, position);

    setBackgroundColor(holder, position);

    return convertView;

}

From source file:com.spitspce.space.ActionDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        category_value = extras.getString("category");
    }/*from   ww  w .ja  va 2 s  .  c o  m*/

    currentUri = new Uri.Builder().scheme(ABOUT_SCHEME).authority(category_value).build();

    setContentView(R.layout.actions_drawer);

    spaceapp = getSharedPreferences("space", 0);
    toast3Flag = spaceapp.getInt("toast3Flag", 1);

    if (toast3Flag != 0)
        FirstToast();

    viewActionsContentView = (ActionsContentView) findViewById(R.id.actionsContentView);
    viewActionsContentView.setSwipingType(ActionsContentView.SWIPING_ALL);

    final ActionBar abar = getSupportActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.title_view, null);
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(//Center the textview in the ActionBar !
            ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
    textviewTitle = (TextView) viewActionBar.findViewById(R.id.title);
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/berlin-sans-fb-demi-bold.ttf");
    textviewTitle.setTypeface(tf);
    textviewTitle.setText(this.getTitle());
    abar.setCustomView(viewActionBar, params);
    abar.setDisplayShowCustomEnabled(true);
    abar.setDisplayShowTitleEnabled(false);
    abar.setHomeButtonEnabled(true);

    final ListView viewActionsList = (ListView) findViewById(R.id.actions);
    final ActionsAdapter actionsAdapter = new ActionsAdapter(this);
    viewActionsList.setAdapter(actionsAdapter);

    viewActionsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View v, int position, long flags) {
            final Uri uri = actionsAdapter.getItem(position);
            updateContent(uri);
            viewActionsContentView.showContent();
        }
    });

    if (savedInstanceState != null) {
        currentUri = Uri.parse(savedInstanceState.getString(STATE_URI));
        currentContentFragmentTag = savedInstanceState.getString(STATE_FRAGMENT_TAG);
    }

    updateContent(currentUri);

}

From source file:com.google.android.apps.santatracker.map.cardstream.CardAdapter.java

public CardAdapter(Context context, CardAdapterListener listener, DestinationCardKeyListener destCardListener,
        boolean isTv) {
    mContext = context;/*from   w  w  w.  ja  va2  s  . c o m*/
    mTypefaceLabel = Typeface.createFromAsset(context.getAssets(),
            context.getResources().getString(R.string.typeface_roboto_black));
    mTypefaceBody = Typeface.createFromAsset(context.getAssets(),
            context.getResources().getString(R.string.typeface_roboto_light));
    mListener = listener;
    mDestinationCardListener = destCardListener;

    TrackerCard.Dashboard dashboard = TrackerCard.Dashboard.getInstance();
    mDashboardId = dashboard.id;
    mCards.add(DASHBOARD_POSITION, dashboard);
    mThumbnailListener = new ThumbnailListener();
    mYouTubeApiDeveloperKey = context.getString(R.string.config_maps_api_key);
    mIsTv = isTv;

    setHasStableIds(true);
}

From source file:com.funzio.pure2D.ui.vo.FontVO.java

public TextOptions createTextOptions(final UIManager manager) {
    final TextOptions options = TextOptions.getDefault();

    options.id = name;/*from   ww  w .ja v a2  s. c  o m*/
    options.inCharacters = manager.evalString(characters);
    options.inMipmaps = texture_mipmaps;

    try {
        options.inTextPaint.setTypeface(
                Typeface.createFromAsset(manager.getContext().getAssets(), manager.evalString(typeface)));
    } catch (Exception e) {
        // Log.e(TAG, "Creating Typeface Error: " + typeface, e);
        // fallback solution
        options.inTextPaint.setTypeface(Typeface.create(typeface, TextOptions.getTypefaceStyle(style)));
    }

    options.inTextPaint.setTextSize(Float.valueOf(manager.evalString(size)) * mScale);
    options.inTextPaint.setColor(Color.parseColor(color));

    options.inPaddingX = padding_x * mScale;
    options.inPaddingY = padding_y * mScale;

    // stroke
    final float ss = Float.valueOf(manager.evalString(stroke_size)) * mScale;
    if (ss > 0) {
        options.inStrokePaint = new TextPaint(options.inTextPaint);
        options.inStrokePaint.setColor(Color.parseColor(stroke_color));
        options.inStrokePaint.setTextSize(ss);
    }

    // shadow
    if (shadow_radius > 0) {
        if (options.inStrokePaint == null) {
            options.inStrokePaint = new TextPaint(options.inTextPaint);
        }
        options.inStrokePaint.setShadowLayer(shadow_radius * mScale, shadow_dx * mScale, shadow_dy * mScale,
                Color.parseColor(shadow_color));
    }

    return options;
}