Android-RobotoTextView 0,0,1,0

Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.

Android-RobotoTextView

Android Arsenal

Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab and Roboto Mono fonts.

Supported fonts:

image

<img alt="Get it on Google Play" src="http://www.android.com/images/brand/get_it_on_play_logo_small.png" />

Compatibility

This library is compatible from API 9 (Android 2.3).

Download

Gradle:

compile 'com.github.johnkil.android-robototextview:robototextview:2.5.1'

Maven:

<dependency>
    <groupId>com.github.johnkil.android-robototextview</groupId>
    <artifactId>robototextview</artifactId>
    <version>2.5.1</version>
    <type>aar</type>
</dependency>

Usage

In XML

To set up a typeface you must specify the parameter typeface:

<com.devspark.robototextview.widget.RobotoTextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:typeface="roboto_light_italic"/>

or specify a set of parameters fontFamily, textWeight and textStyle:

<com.devspark.robototextview.widget.RobotoTextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fontFamily="roboto"
            app:textWeight="light"
            app:textStyle="italic"/>

Set up typeface in code:

In Code

Using parameter typeface:

RobotoTextView textView = new RobotoTextView(context);
Typeface typeface = RobotoTypefaceManager.obtainTypeface(
        context, 
        RobotoTypefaceManager.Typeface.ROBOTO_LIGHT_ITALIC);
RobotoTypefaceUtils.setUp(textView, typeface);

Using parameters fontFamily, textWeight and textStyle:

RobotoTextView textView = new RobotoTextView(context);
Typeface typeface = RobotoTypefaceManager.obtainTypeface(
        context, 
        RobotoTypefaceManager.FontFamily.ROBOTO,
        RobotoTypefaceManager.TextWeight.LIGHT,
        RobotoTypefaceManager.TextStyle.ITALIC);
RobotoTypefaceUtils.setUp(textView, typeface);

With Span

Using parameter typeface:

RobotoTypefaceSpan span = new RobotoTypefaceSpan(
        context,
        RobotoTypefaceManager.Typeface.ROBOTO_BOLD);
Spannable spannable = new SpannableString("text");
spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Using parameters fontFamily, textWeight and textStyle:

RobotoTypefaceSpan span = new RobotoTypefaceSpan(
        context,
        RobotoTypefaceManager.FontFamily.ROBOTO,
        RobotoTypefaceManager.TextWeight.LIGHT,
        RobotoTypefaceManager.TextStyle.ITALIC);
Spannable spannable = new SpannableString("text");
spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Gradle

If you intend to use is not all fonts, the extra fonts can be removed.

android.applicationVariants.all{ variant ->
    variant.mergeAssets.doFirst {
        File fonts = file("${projectDir}/build/intermediates/exploded-aar/com.github.johnkil.android-robototextview/robototextview/2.5.1/assets/fonts")
        if (fonts.exists()) {
            for (File file : fonts.listFiles()) {
                if (file.getName().contains("RobotoSlab")) {
                    println("delete " + file.getName() + " font")
                    file.delete()
                };
            }
        }
    }
}

License

Copyright 2014 Evgeny Shishkin

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.

Related Repositories

android-open-project

android-open-project

Collect and classify android open source projects, 交流 QQ 群:6322(入群理由必须填写群介绍问题答案) ...

android-open-project

android-open-project

Collect and classify android open source projects, 交流 QQ 群:(入群理由必须填写群简介问题答案)1857 ...

android-open-project

android-open-project

Collect and classify android open source projects, 交流 QQ 群:(入群理由必须填写群简介问题答案)1857 ...

android-open-project

android-open-project

Collect and classify android open source projects, 交流 QQ 群:14884(入群理由必须填写群简介问题答案 ...

android-open-project

android-open-project

Collect and classify android open source projects 微信公众号:codekk 网站: ...


Top Contributors

johnkil OlegKrikun intrications bdbergeron saik0

Releases

-   2.5.1 zip tar
-   2.5.0 zip tar
-   2.4.3 zip tar
-   2.4.2 zip tar
-   2.4.1 zip tar
-   2.4.0 zip tar
-   2.3.0 zip tar
-   2.2.0 zip tar
-   2.1.0 zip tar
-   2.0.1 zip tar
-   2.0.0 zip tar
-   1.5 zip tar
-   1.4 zip tar
-   1.3 zip tar
-   1.2 zip tar
-   1.1 zip tar
-   1.0 zip tar