Function: Click the text to open a URL.
URLSpan(String url)
SpannableStringBuilder ssb = new SpannableStringBuilder (content); ssb. setSpan (new URLSpan ("https://github.com/CaMnter"), start, sub. length (), Spanned. SPAN_INCLUSIVE_INCLUSIVE); contentTV. setText (ssb); // when you click a link, you must set the MovementMethod object contentTV for all actions to be performed. setMovementMethod (LinkMovementMethod. getInstance (); // sets the color after a click. Here, the ClickableSpan click bac
brandtextview (context context) { super (context); public void setTypeface (Typeface TF, int style) {if (style = = Typeface.bold) {super.settypeface (Typeface.createfromasset (GetContext (). Getassets (), else {super.settypeface (Typeface.createfromasset ( GetContext (). Getassets (), "Fonts/yourcustomfont.ttf"); } } }Then just replace the standard text control with your custom (for example, Brandtextview to replace TextView).com.your.package.BrandT
This example describes how to use custom fonts in Android. Android supports TureType fonts, which are the same as Windows supports TrueType fonts.
You can view the font in the Windows \ Fonts directory, for example, copy the Edwardian font to the assest \ fonts directory in this example:
Modify the code in this example:
[Java]Private static class SampleView extends View {Private Paint mPaint = new Paint (Paint. ANTI_ALIAS_FLAG );Private Typeface mFac
CssWhat is the use of network systems, we create two basic designs-one that usesFlexbox, another use grid system, try it. WebFront End LearningUseThe Flexbox build layout actually just helps you put two projects together, which means that it turns all child elements into "pseudo-inline elements" (just presented). This also means that you have to consider how to place HTML elements. Each div-element, is about to become a row of useFlexboxwill become a container. I finally got my basic layout and
Set the color and font of the control.
Code:
Package com. oyzz. a7_6;
Import Android. App. activity;/* The graphics. Color must be referenced to use the color. * object */Import Android. Graphics. color;Import Android. Graphics. typeface;
Import Android. OS. Bundle;Import Android. View. view;
/* Widget. Button must be referenced to declare the use of the button object */Import Android. widget. Button;
/* You must reference widget. textview to declare
Code:
Package com. oyzz. a7_6;
Import Android. App. activity;/* The graphics. Color must be referenced to use the color. * object */Import Android. Graphics. color;Import Android. Graphics. typeface;
Import Android. OS. Bundle;Import Android. View. view;
/* Widget. Button must be referenced to declare the use of the button object */Import Android. widget. Button;
/* You must reference widget. textview to declare the use of the testview objec
brush color.
Setargb (int A, int r, int g, int b)
void
Sets the brush's a (transparency), R (red), G (green), B (blue), Value (0X00000000-0XFFFFFFFF). The single value range is 0-255.
Settypeface (Typeface Typeface)
Typeface
Set the font, through the typeface can load
not provide the Font class below the j2's, instead of Typeface, which provides readers with more options, because Typeface can be customized, however, in order to seamlessly port the j2's program to the Android platform, the author encapsulates a Font class similar to that under the j2's platform, as shown below:
Import android. graphics. Typeface;
Public clas
1. set the system default font in the Android XML fileYou can use Android:typeface to set fonts in an XML file , such as android:typeface= "monospace". In this example, we in the activity of android:text= "Hello, world! hello " respectively carried out four kinds of display methods, followed by "Sans","serif"," Monospace "and system default mode (using Sans by default ). English fonts are different, seemingly Chinese fonts do not differ. The XML file is as follows: "sans:" android:layo
Public class abouttextview extends textview {Public static int m_itextheight; // text heightPublic static int m_itextwidth; // text widthPrivate paint mpaint = NULL;Private string = "";Private float linespace = 0; // line spacingPublic abouttextview (context, attributeset set){Super (context, set );
Rect = new rect ();Getwindowvisibledisplayframe (rect );Float rate = (float) rect. Right/600;Float interval wwidth = (600-30) * rate;Typedarray = context. obtainstyledattributes (set, R. styleable. c
About Android custom FontsI used the following statement to customize the font of the content:Textview TV = (textview) findviewbyid (R. Id. maintitle );// Change the fontTypeface face = typeface. createfromasset (getassets (), "fonts/hyyy. TTF ");TV. settypeface (FACE );Import the font file hyyy. TTF in assets/front. The size is 3.37 MB.But the program does not know why it cannot run.The following figure shows the logcat:04-01 02:33:21. 338: E/android
First step: Create a new Android project, create a new folder in the assets directory, the name can be arbitrary,I'm named fonts here.Step two: Copy the font file to this new directory (there are many font files in the C:\Windows\Fonts directory in the Windows system)Step three, create a static method under Mainactivity//Because reading a font file into memory is a time-consuming operation, if the font file is larger, there will beIt is obvious that the type
ArticleDirectory
Intro free font
Stiff staff font
Archive
Governor an Art Deco alphabet
Rbno2
Kilogram
Infinity
Hagin font
Prime font
FV Almelo
Rex free font
Forum font
Code pro
Color lines free font
Kankin font
Habana font
Cube 02 font
Cube font
Bender font
Muncie font
Croissant-free Google Web font
Null free font
Cassannet font
Facunda font
Multicolore Fonts
Plstk font
Chrome light font
Myra font
Metropolis
The TextView font support is limited in the Android operating system. By default, the typeface attribute of TextView supports three fonts: "Sans", "serif", and "monospace, if no font is specified, the system uses "Sans" as the text display font by default. However, these three fonts only support English. That is to say, as long as you display Chinese characters, the display effect is the same no matter which one of the three fonts you choose. To this
Android switches the third-party font for the entire application, and android third-party font
I,
1. Obtain and replace the system font through reflection
import java.lang.reflect.Field;import android.content.Context;import android.graphics.Typeface;public final class FontsOverride { public static void setDefaultFont(Context context, String staticTypefaceFieldName, String fontAssetName) { final Typeface regular = Typeface.createF
set in effect.Dt_wordbreak: Interrupts the word. Lines are automatically interrupted between words if the word expands beyond the bounding rectangle specified by the lprect parameter. When not specified, the output is in one row.Dt_word_ellipsis: Truncate word does not fit rectangle, add ellipsis.Successful, returns the text height. Logical units.When Dt_vcenter or Dt_bottom is specified, the return value is the offset lprect->top to the bottom of the drawing text.Failed, 0The text alignment mo
Android switches the third-party font for the entire application
I,
1. Obtain and replace the system font through reflection
import java.lang.reflect.Field;import android.content.Context;import android.graphics.Typeface;public final class FontsOverride { public static void setDefaultFont(Context context, String staticTypefaceFieldName, String fontAssetName) { final Typeface regular = Typeface.createFromAsset(context.getAssets(),
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
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.