Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8981721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:24:25+00:00 2026-06-15T20:24:25+00:00

In my application I am implementing 5 different Custom App Themes . I am

  • 0

In my application I am implementing 5 different Custom App Themes.

I am using 5 different fonts for these themes for which I have created CustomTextview which extends a Textview. Following is the format in which it is created.

public class CustomFontTextView extends TextView {
private static final String CUSTOM_FONT = "Custom-Regular.ttf";
private static final String TAG = CustomFontTextView.class.getName();

public CustomFontTextView(Context context) {
    super(context);

    if (android.os.Build.VERSION.SDK_INT < 14) {
        setCustomFont(context, CUSTOM_FONT);
    }
}

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

    if (android.os.Build.VERSION.SDK_INT < 14) {
        setCustomFont(context, CUSTOM_FONT);
    }
}

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

    if (android.os.Build.VERSION.SDK_INT < 14) {
        setCustomFont(context, CUSTOM_FONT);
    }    
}

public boolean setCustomFont(Context ctx, String fontFile) {
    try {
        setTypeface(Typeface.createFromAsset(ctx.getAssets(), fontFile));       
        return true;

    } catch (Exception e) {
        Log.e(TAG, "Could not get typeface: "+e.getMessage());
        return false;
    }
}

}

I was using the custom textview in the XML layouts.

    <com.myapp.android.fonts.CustomFontTextView
    android:id="@+id/Text_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@string/my_text_content"
    android:textColor="@android:color/white"
    android:textSize="22sp" />

But for implementing the different themes I have to find some methods which would change all my textviews according to the themes selected.

Is there any way by which I can set the fonts within my theme,

      <style name="MyCustomTheme" parent="android:style/Theme">
               ..............   ......................
             ...........     ...................
         <item name="android:textColorPrimary">#000000</item>
         <item name="android:buttonStyle">@style/MyCustomButton</item>
      </style>

I want to implement this without disturbing the code as there are a lot of UI components involved.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:24:26+00:00Added an answer on June 15, 2026 at 8:24 pm

    Create a custom attribute for the font and include it in the style. In your CustomView class, access this attribute and set the font accordingly.

    Check Creating a View Class for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a web application which will support different views according to different browsers.
I am implementing a small demo application which encrypts using AES CTR with OpenSSL
I am implementing the application which consumes webservice (first authentication and then calling different
HI, I am implementing a custom role provider in my nhibernate application I have
I am implementing an JAVA application which takes data from different URL's and store
I have started implementing my application using phone gap and Sencha Touch . I
I have an application implementing incremental search. I have a catalog of unicode strings
I am implementing an application using ember.js and couchdb. I choose ember-resource as database
I'm implementing an application which want to draw lines in the panel. But the
I am currently implementing the application that displays hierarchy using ListBoxes (please do not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.