Giter Club home page Giter Club logo

xamdroid.robototext's Introduction

XamDroid.RobotoText

Implementation backwards compatibility Roboto font in any control!.

Read the blog posts: RobotTextView RobotoTextFactory

Demo

Sample Factory

Getting started

Installing the library

Add library to your project or clone it and do the following:

  • Add all fonts into Asses/fonts and ensure they are marked as AndroidAsset as the build action
  • Add RobotoTextView and feel free to change the namespace
  • Add the custom attributes in the attrs.xml in your Resources/Values folder.

Usage

In any layout that you wish to use the Roboto Font simply include a new xmlns

xmlns:local="http://schemas.android.com/apk/res-auto"

Then create a new RobotoTextView

<com.refractored.controls.RobotoTextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          local:typeface="roboto_thin"
          android:text="Roboto Thin"
          android:textAppearance="?android:attr/textAppearanceMedium" />

The most important part is: local:typeface

Valid options are:

  • roboto_thin
  • roboto_thin_italic
  • roboto_light
  • roboto_light_italic
  • roboto_regular
  • roboto_medium
  • roboto_medium_italic
  • roboto_bold
  • roboto_bold_italic
  • roboto_black
  • roboto_black_italic
  • roboto_condensed
  • roboto_condensed_italic
  • roboto_condensed_bold
  • roboto_condensed_bold_italic

Expanding

You can apply this same concept to any other control such as a CheckedTextView.

Expand with custom LayoutInflator Factory

Also included is RobotoTextFactory. If you want you will still need the typeface enum attribute but this will allow you to add the typeface to any View that derives from TextView such as Button, CheckBox, etc. All you will need to do is set the RobotoTextFactory before SetContentView is called:

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    LayoutInflater.Factory = new RobotoTextFactory();
    // Set our view from the "main" layout resource
    this.SetContentView(Resource.Layout.Main);
}

In your axml file all you need to do is add the custom attribute onto any of your Views:

<CheckBox
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="CheckBox with Roboto Thin"
     local:typeface="roboto_thin" />

This will result in something like this: Factory

Development:

Ported and Maintained by: James Montemagno (@JamesMontemagno)

Original Concept on (Stack Overflow)

License

Copyright 2013 James Montemagno

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

xamdroid.robototext's People

Contributors

jamesmontemagno avatar

Stargazers

 avatar Carla Papalardo avatar Łukasz Goliński avatar  avatar Alkhatib Hamad Adam avatar  avatar Ernest Mashele avatar An Ngo avatar Sergiy Martyniuk avatar  avatar Luis Hernandez avatar Jose Manuel Montero avatar

Watchers

James Cloos avatar  avatar  avatar

xamdroid.robototext's Issues

Application crashes in Moto 4.4.4

I'm using RobotoTextView in My Application but it crashes in the Moto- 4.4.4 device also i have download the sample and run it in same device but it happens in sample too.
While debugging i found that during initialisation on RobotoTextview on below line of code application crashes
int typefaceValue = values.GetInt(Resource.Styleable.RobotoTextView_typeface, 0);

I've used the same application in Samsung 4.4.4 device application working fine.

I'm not getting the problem with this device.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.