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 example, Android: text = "Hello, world! Hello, there are four display modes: "sans", "serif", "monospace", and system default mode (SANS by default ). There are differences in English fonts. It seems that there are no
;
Copy Code code as follows:
Get TextView Control Object
TextView TextView = (TextView) Findviewbyid (R.id.custom);
Save the font file in the assets/fonts/directory, www.linuxidc.com create the typeface object
Typeface typeface = Typeface.createfromasset (Getassets (), "Fonts/droidsansthai.ttf");
Apply Font
Textview.settypeface (
At the beginning of the concept is only a little vague, not too concerned about, the results of a search only found that this thing is too interesting, not only has an interesting story, but also has a lot of doorways, but also brought up some of the previous memories, the original previously also dealt with this problem.1 Basic Concepts
Control characters
Original meaning
Line break
\ n
NewLine
LF (line Feed)
The cursor go
Line breaks in Linux and Windows
Carriage Return and line feed generate background
The origins and differences between carriage return and line feed.Before the computer appeared, there was a kind of device called teletype model 33, which can contain 10 characters per second. But there is a problem, that is, when a line breaks a line, it takes 0.2 seconds, just two characters. If a new character is passed in the 0.2 s, the character will be lost.As a result, the developers thought of a way to sol
Http://casec12.javaeye.com/blog/523160
Today, I have finally figured out the origins and differences between carriage return and line feed.Before the computer appeared, there was a kind of device called teletype model 33, which can contain 10 characters per second. But there is a problem, that is, when a line breaks a line, it takes 0.2 seconds, just two characters. If a new character is passed in the 0.2 s, the character will be lost.
As a result, the developers thought of a way to solve this p
they have already visited. They open an article or a book, usually reading one or two pages, and then jump to another place. The report said: "It is obvious that users are not reading online in traditional ways. On the contrary, there are signs of a new 'read' method: users browse the titles, content pages, and summaries in a massive manner to get results quickly. It is almost considered that they are surfing the Internet to avoid reading in the traditional sense ."
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 MSP. setspan (New backgroundcolorspan (color. cyan), 15, 18, spanned. span_exclusive_exclusive); // set the background color to cyan // set the font style to normal, bold, italic, and bold italic. setspan (New stylespan (Android. graphics. typeface. normal), 18, 20, spanne
) ---- set the font size. The parameter is an 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 setti
Control of different text fonts in development is mainly the use of typeface objectsBecause it is a simple demo, are using the Android native components, although ugly, you can learn something is OK! (if there are errors or deficiencies, please enlighten me, thank you!) )Let's take a look at the simple running effect. That is, setting two buttons, one TextView, and clicking a different button triggers a different event. Directly on the
Drawable objects associated with this view.Void onMeasure (int widthMeasureSpec, int heightMeasureSpec)Measure the view and its content to determine the measured width and the measured height.Void onPopulateAccessibilityEvent (AccessibilityEvent event)Called from dispatchPopulateAccessibilityEvent (AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.Boolean onTouchEvent (MotionEvent ev)Implement this method to handle touch screen motion eve
, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE );Msp. setSpan (new AbsoluteSizeSpan (20, true), 6, 8, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE); // The second parameter boolean dip. If it is true, it indicates that the front font size is in dip; otherwise, it is pixel, same as above.// Set the font size (relative value, unit: pixel) to the number of times the default font sizeMsp. setSpan (new RelativeSizeSpan (0.5f), 8, 10, Spanned. SPAN_EXCLUSIVE_EXCLUSIVE); // 0.5f indicates half of the default font sizeMsp. s
(R.id.custom);
Save the font file in the assets/fonts/directory, www.linuxidc.com create the typeface object
Typeface typeface = Typeface.createfromasset (Getassets (), "Fonts/droidsansthai.ttf");
Apply Font
Textview.settypeface (typeface);
If you want to apply a custom font to all controls on the entire interfac
Before you implement the progress bar, learn the makefile first.There are countless source files in a project, which are placed in several directories by type, function and module, and makefile defines a series of rules to specify which files need to be compiled first, which files need to be compiled, which files need to be recompiled, and even more complex functional operations. Make is a command tool that is a command tool that interprets instructions in makefile.Beginners can only implement
you can browse with VC6.0 in Windows.) )。 To open the command can also be entered directly: (Note that if the filename is Chinese, it may not be found, need LS, and then copy the filename, and then gedit paste the file name)
Gedit Xx.doc
or Vim Xx.doc (not recommended, VIM may not support traditional characters)
or directly find the file, click, Open Office, select the character set (System), character (SYSong18030), language (Simplified Chinese), change paragraph:
1. Crlf, that is, \ r \ n, th
The difference between Linux and Windows return line break
source of the problem: "Carriage return" (carriage return) VS "line feed"Before the computer appeared, there was a gadget called a telex typewriter (teletype Model 33) that could play 10 characters per second. But it has a problem, that is, when the line is finished, it will take 0.2 seconds to hit two characters. If there are new characters coming in this 0.2 seconds, then this character wil
menu) {// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater (). inflate (R. menu. main, menu); return true ;}}
AbsoluteSizeSpan (int size) ---- set the font size. The parameter is an absolute value, which is equivalent to the font size RelativeSizeSpan (float proportion) in Word ---- 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, which is flex
parameter is the font name, such as "sans" and "sans-serif ".
StyleSpan (Typeface style) ----- font style, such as BOLD and ITALIC. The parameters are constants defined in android. graphics. Typeface, such as Typeface. BOLD and Typeface. ITALIC.
StrikethroughSpan ---- if this style is set, there will be a line passi
In Android operating system development, a basic operation is very common for graphic interface operations. We can first use the operations related to Android plotting described in this article to learn more about the operation skills of a single interface, so as to improve our awareness of this system.
Import java. io. InputStream;
Import android. app. Activity;
Import android. content. Context;
Import android. graphics. Bitmap;
Import android. graphics. BitmapFactory;
Import and
1, the Android system supports three kinds of fonts by default: "Sans", "serif", "monospace2. Other fonts can be introduced in Android.Get the TextView control object TextView TextView = (textView) Findviewbyid (r.id.custom);//Save the font file in the assets/fonts/directory, Www.linuxidc.com Create TypeFace object TypeFace typeFace = Typeface.createfromasset (Ge
, mpaint); $Canvas.drawtext ("Descent", BaseX +textWidth, Descenty, mpaint);Panax Notoginseng //Buttomline Depiction - Mpaint.setcolor (Color.magenta); theCanvas.drawline (BaseX, bottomy, BaseX +textWidth, bottomy, mpaint); +Canvas.drawtext ("Buttom", BaseX + textWidth, bottomy + ten, mpaint);Believe that through the above procedures, can be a good understanding of topline,buttomline,baseline,ascentline,descentline.In addition: There are two methods of the paint class1 /**2 * Return The distance
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.