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 <br/> * Create at October 26, 2014 6:46:05 */public class ledtextview extends textview {Private Static final string tag = "ledtextview"; Public ledtextview (context) {super (context); Init (context);} public ledtextview (context, attributeset attrs) {super (context, attrs); Init (context );} public ledtextview (context, attributeset attrs, int defstyle) {super (context, attrs, defstyle); Init (context);} private void Init (context) {// Add the font resource to the assets folder. assetmanager AM = context. getassets (); typeface font = typeface. createfromasset (AM, "fonts/digital-7.ttf"); settypeface (font );}
Reference ledtextview in layout File
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:background="@android:color/black" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <com.led.demo.LedTextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#00ff00" android:text="12:00:00" android:shadowColor="#00ff00" android:shadowDx="0" android:shadowDy="0" android:textSize="20sp" /></RelativeLayout>
After the settings are completed, the above results will be displayed.
Textview uses a Custom font and is highlighted