Showing posts from July, 2014

Using Custom fonts through XML.

1st Create the custom TextView through java,

package com.example.customfont;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;
public class CustomTextView extends TextView {
    private static final String TAG = "TextView";
    public CustomTextView(Context context) {
    public CustomTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setCustomFont(context, attrs);
    public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setCustomFont(context, attrs);
    private void setCustomFont(Context ctx, AttributeSet attrs) {
        TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.TextViewPlus);
        String customFont = a.getString(R.styleable.CustomTextView_customFont);
        setCustomFont(ctx, cust…

Highlight text on EditText

If somebodies want to click to highlight the text in edittext,

Just add one line in XML,


to highlight the text.


Clear Highlight text.
Change the new text.