Textview uses a Custom font and is highlighted

Source: Internet
Author: User

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

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.