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

  • Home
  • SEARCH
  • 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 8789197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:20:12+00:00 2026-06-13T22:20:12+00:00

Absolute Android development beginner here, so please bear with me. I am trying to

  • 0

Absolute Android development beginner here, so please bear with me. I am trying to achieve 2 things with my title in the ActionBar:

  1. Center align the title text
  2. Use a custom font for the title text

I’m trying to follow this answer, so please look at that answer first.

Contents of MainActivity.java

    // ATTEMPT TO STYLE THE ACTIONBAR
    this.getActionBar().setDisplayShowCustomEnabled(true);
    this.getActionBar().setDisplayShowTitleEnabled(false);

    LayoutInflater inflator = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.titleview, null);

    //if you need to customize anything else about the text, do it here.
    //I'm using a custom TextView with a custom font in my layout xml so all I need to do is set title
    ((TextView)v.findViewById(R.id.title)).setText(this.getTitle());

    //assign the view to the actionbar
    this.getActionBar().setCustomView(v);

I created a new XML file: layout/titleview.xml to correspond to R.layout.titleview above. It contains:

<com.muppethead.app.name.CustomTextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="10dp"
    android:textSize="20dp"
    android:maxLines="1"
    android:ellipsize="end"
    android:text="MY APP TITLE" />

This gives the error:
The following classes could not be found: com.muppethead.app.name.CustomTextView

Question

Where am I going wrong? In addition to fixing the above error, where do I reference my font, which is located in assets/fonts/font.otf? And what about centering the text?

I gotta say, shame on Google for not making this possible from the XML. It removes the possibility for new developers to create anything attractive.

Thanks in advance for your help.

  • 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-13T22:20:14+00:00Added an answer on June 13, 2026 at 10:20 pm

    What I would honestly do is forget about the custom TextView, and just use the default one in the XML. You’re using it just this once, and only for the custom font.

    You can do something like this instead:

    TextView tv = (TextView) v.findViewById(R.id.title);
    Typeface tf = Typeface.createFromFile(getAssets(), "fonts/font.otf");
    tv.setTypeface(tf);
    tv.setText(this.getTitle());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm an absolute beginner at Android programming, so please bear with me :) For
I'm absolute beginner in Android apps development. I created a main menu with buttons.
I'm absolute beginner to mono for android . Following buttons are created dynamically and
I'm absolute beginner when it comes to mono for android . I've used following
I'm absolute beginner when it comes to mono for android . Referring to below
I am a absolute beginner in Windows Phone Development with a basic idea in
Hi Im trying to create a simple android page with text at the top
Absolute beginner question: I have a template file index.html that looks like this: ...
I'm almost an absolute beginner in Python, but I am asked to manage some
Hello i am an absolute beginner on cloud computing and on python. I would

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.