In this example, set the font style for all the controls on the interface at one time. The idea is to find the parent control and traverse the child control. If the child control is a control that can modify text, set text. This applies to control inheritance. Many controls are inherited from textview, so convert the controls into textview and set the font.
Layout File
Mainactivity
Package COM. kale. font; import android. app. activity; import android. graphics.
size.Typeface settypeface (typeface) // sets the font. typeface includes the font type, width, skew, and color.
Void setunderlinetext (Boolean underlinetext) // set the underlineIn the end, canvas and paint are directly used in ondraw.
[Java]View plaincopyprint?
Protected void ondraw (canvas ){
Paint paintred = new paint ();
Paintred. setcolor (color. Red );
Canvas. drawpoint (11,3, paintred);
Document directory
Use Image replacement
@ Font-face
Sifr
Typeface. js
Beautiful fonts are a magic weapon for designers, but in web design, this magic weapon is almost ineffective.Custom fontIt is often because the user's computer does not prefabricate the font and cannot be displayed in the desired way. This article will provide some solutions for this problem. After balancing the advantages and disadvantages, I believe there is always a suit
absolute value, which is equivalent to the font size in word.
Relativesizespan (float proportion) ---- set the font size. The parameter is a multiple of the default font size. For example, if the default font size is X, the configured font size is x * proportion, this is more flexible to use. proportion> 1 is zoom in, and proportion
Scalexspan (float proportion) ---- scale the font. Similar to the preceding one, the default value is 1. After setting it, It is multiplied by proportion. If it
Recently, the project needs to develop a circular scrolling subtitle function. I found relevant materials and implemented the function in two ways based on my own style;
(Note: I only implement the scrolling effect, and I have not done any processing on text format formatting. The format may be messy and Text Formatting is still under study)
:
The details are as follows;
Method 1: Transverse scrolling Subtitles inherit textview
Package COM. example. playpic; import COM. example. playpic.
Android uses custom FontsPreface
Android has its own default font, but sometimes we don't want to use its default font. We want to use fonts such as and. How can we do this? This article describes how to use a Custom font.Implementation
Zookeeper first comes with a source code:
Public class MainActivity extends Activity {
@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (new CustomView (this);} class CustomView extends View {pr
TextView uses a Custom font and is highlighted. textview is highlighted.
Respect Originality:Http://blog.csdn.net/yuanzeyao/article/details/40478815
Currently, many applications like to use custom fonts. Today I will use custom fonts in TextView and set the highlight. The display effect is as follows:
Define LedTextView. java
/*** Highlighted TextView * com. led. demo. ledTextView * @ author yuanzeyao
Reference LedTextView in layout File
After the settings are completed, the above results
: hollow
4. The setStrokeWidth method is used to set the hollow width of the paint brush. This method has obvious effects on rectangles, circles, and other images.Public void setStrokeWidth (float width) // The parameter width is the width of the float data.
5. The setTextSize method is used to set the font size of the paint brush. It is mainly used to draw strings.Public void setTextSize (float textSize )//
6. The setTypeface method is used to set the font style of the paint brush. You can use
value is 1. After setting it, It is multiplied by proportion. If it is greater than 1, it is zoon in ), zoom out ).
BackgroundColorSpan (int color): Specifies the background Color. The parameter is a Color value. You can directly use the constant defined in android. graphics. color or use Color. rgb (int, int, int ).
ForegroundColorSpan (int color): Specifies the foreground color, that is, the color of the word. The parameter is consistent with that of the background color.
TypefaceSpan (String
, width, textsize, and textcolor. You can assign values to these attributes, but have you ever understood how to get the value? If you don't know it, it doesn't matter. I have a more detailed article on Hongyang. I recommend it to you: Baidu.
2. Custom Control Source Code 1:
Package com. example. testdemo. view; import android. annotation. suppressLint; import android. content. context; import android. content. res. typedArray; import android. graphics. canvas; import android. graphics. color;
Linux. Assume that the Chinese font in Windows has been copied/Usr/share/fonts/winfonts/Directory, the gs configuration fileCidfmap. zh_CNMake some modifications so that gs can use the Windows Chinese font in Linux:
% Cidfmap. original contents remain unchanged in zh_CN/BousungEG-Light-GB
Use the editor to create a PS file (yes, the PS file contains plain text, which can be edited directly in the editor !), NameGs_test.ps, The content is:
%! PS-Adobe-3. 0/STSong-Light -- UniGB-UTF8-H findfont
Android provides three fonts: "sans", "serif", and "monospace ".
1. Set the font in the android XML file
Android: Typeface can be used, for example, Android: Typeface = "monospace ". In this exampleFor Android: text = "Hello, world!Hello, there are four display modes: "sans", "serif", "monospace", and system default mode (SANS by default ). English fonts availableDifferences, it seems that there is no diffe
, spanned. span_exclusive_exclusive); // 2.0f indicates twice the default font width, that is, to enlarge the X axis to twice the default font width, while the height remains unchanged. // set the font size (relative value, unit: pixel) parameter indicates how many times the default font size mspannablestring. setspan (New relativesizespan (0.5f), 8, 10, spanned. span_exclusive_exclusive); // 0.5f indicates half of the default font size mspannablestring. setspan (New relativesizespan (2.0f), 10,
When you do a project, you need to use the handwriting font to make the content more beautiful. However, the default application of the system is the default font, how to set the TextView (or edittext) font to the font you want it? The steps are as follows:1. Download the font file (. ttf format), such as Jinglei.ttf (Founder's font file), and copy it to the project's assets/fonts directory.2, set the font of TextView:1 TextView TV = (TextView) Findviewbyid (R.id.my_textview); 2
Recent projects appear to set the font to the song body, Microsoft Ya Black, bold, italic and other needs;Mom found Android system supports three fonts by default: "Sans", "serif", "monospace", in addition to other font files (*.TTF)The code is as follows:Get TextView Control ObjectTextView TextView = (TextView) Findviewbyid (R.id.custom);Save the font file in the assets/fonts/directory and create the typeface objectTypeface
One, custom fonts1.android typeface setting fonts using TTF font filesWe can put the TTF font file in the program and use typeface to set the font in the program.The first step is to create a new fonts directory under the assets directory and place the TTF font file here.In the second step, the program calls:[Java] view plaincopy
Assetmanager mgr=getassets (); //Get Assetmanager
does not support the getComputedStyle () method, but provides a simpler alternative. Each HTML element has a currentStyle attribute to control its calculated style. The only drawback of IE's API is that it cannot provide a way to query pseudo object styles. As an example of the calculated style, you can use the following cross-platform code to confirm the font of the element:
Copy to ClipboardReference: [www.bkjia.com] var p = document. getElementsByTagName ("p") [0]; // Get first paragraph of
source represents the parcel which contains the data of the corresponding object. During This method can extract the data fields in the same sequence as you put them into the Parcel During the WriteTo Parcel method. These fields can and is used to create a instance of the object.T[] NewArray (int size)This method returns just an empty array of the object with a given size.Defining the Parcelable Message ClassNow so we know what we had to implement when creating a class which implements the Parc
the default font size msp. setSpan (new RelativeSizeSpan (0.5f), 8, 10, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE); // 0.5f indicates half of the default font size. setSpan (new RelativeSizeSpan (2.0f), 10, 12, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE); // 2.0f indicates twice the default font size. // set the foreground color of the font msp. setSpan (new ForegroundColorSpan (Color. MAGENTA), 12, 15, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE); // set the foreground color to magenta // set the font background color m
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.