Android for TV-powered: (reprint) modify TextView font style

Source: Internet
Author: User

First, the outset

Because Android font-related content is also more. Sometimes we just need to adjust the properties to meet the needs of the designer, or a back-up plan (after all, the time of the release is stuck), some of the effects can probably meet the needs.

So this article first introduces some of the basic concepts and uses of some fonts built into Android.

It is important to note that some of the built-in fonts are only valid in English.

Second, the default font for Android

The Android system uses a font called robote by default. Robote itself is Google's own font format, and on Android and Chrome OS, robote fonts are used by default and are also recommended in the Google visual language.

To find out more about Robote, you can go to Google's website to view it.

Https://fonts.google.com/specimen/Roboto

Normally, Robote has a variety of options, such as weight, italic, and so on. But usually it doesn't meet the needs of our designers.

Let's take a look at what properties we need to use when we want to use some of the fonts built into Android.

Three, which attributes can affect the font

Android itself has provided some properties and methods for modifying font styles.

When you want to modify the font, you will face three properties, all of which have a corresponding Java method.

    • Android:textstyle
    • Android:typeface
    • Android:fontfamily

These properties are described in detail below.

3.1 Android:textstyle

textStyleMainly used to set the style of some fonts, it is for all the fonts are in effect. This means that even if you replace the font, you can still use textStyle it to modify its style. The TextStyle itself supports options normal|bold|italic , and they are also very well understood, that is 普通|粗体|斜体 .

As you can see, the font is unaffected textStyle and affects only its style.

3.2 Android:typeface

typefaceCan be used to set some default font, it has optional properties to have, normal|sans|serif|monospace and so on. Normal and Sans fonts are actually the same, serif is a serif font, and nonospace is the equal width font.

In fact, it is not possible to understand them in the light of the above, and the direct comparison can explain the problem.

You can see the serif on the default font, adding a liner. The nonospace limits the width of each character, allowing them to achieve an equal-width effect.

The equal width in fact very good understanding, what is the liner exactly mean? Here is a picture of Wikipedia that gives you a visual explanation of the problem.

Liner is actually the font edge of that little tweet.

3.3 android:fontfamily

fontFamilyIt looks like it's right typeface . A reinforcement, from its optional can be seen, it is more careful to distinguish the style of the font.

fontFamilyThe options are still many, here is not listed. However, it is important to note that there are some font settings that are version-restricted.

For example, the sans-serif-medium version that requires Android 5.0 is supported.

Here are just a few examples to see the effect:

It is important to note that the typeface fontFamily configured font will be used if both and is configured. fontFamily

In addition typeface to fontFamily conflicts, both of them can be typeStyle used together with attributes, that is, the font configured here can be bold or italic.

Android for TV-powered: (reprint) modify TextView font style

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.