Android Open Source - Android-TextFontStyle Text View Style






From Project

Back to project page Android-TextFontStyle.

License

The source code is released under:

Apache License

If you think the Android project Android-TextFontStyle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.raychenon;
// ww  w.j a v a  2 s  .c om
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * User: raychenon
 * Date: 15/7/13
 * Time: 9:00 PM
 */
public class TextViewStyle extends TextView {

    public TextViewStyle(Context context) {
        super(context);
    }

    public TextViewStyle(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_textfontstyle_fontstyle);
        CharSequence s = a.getString(R.styleable.com_textfontstyle_fontstyle_typeFace);
        if (s != null) {
            Typeface typeface = Typeface.createFromAsset(context.getAssets(), s.toString());
            this.setTypeface(typeface);

        }
        a.recycle();
    }

    public TextViewStyle(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

}




Java Source Code List

com.raychenon.TextViewStyle.java
com.textstyle.sample.ProgrammaticTextActivity.java
com.textstyle.sample.SampleList.java
com.textstyle.sample.SimpleTextActivity.java
com.textstyle.sample.StyleTextActivity.java