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 6757631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:40:33+00:00 2026-05-26T13:40:33+00:00

I am making a custom titlebar using the following xml file: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/myTitle

  • 0

I am making a custom titlebar using the following xml file:

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/myTitle"
 android:text="custom title bar"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="@drawable/background" />

And inside my activity’s onCreate() i have the following code:

public class CustomTitleBar extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
            setContentView(R.layout.main);
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
    }
}

The title bar is coming no problem.The image i am setting as background(the name of image is background too as u can see in above xml) is also coming.But the problem is in both right and left side of the image there is remaining a little gap i.e the image is not covering the whole width of parent though the layout_width has been set to “fill_parent”.

Anyone any idea.plz 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-05-26T13:40:34+00:00Added an answer on May 26, 2026 at 1:40 pm

    The little gap to the left/right is added by the framework since the default windowTitleBackgroundStyle in the standard theme used a 9-patch drawable with that padding. Here’s an example on how to override this:

    In AndroidManifest.xml, add an android:theme for your Activity:

    <activity
        android:theme="@style/MyCustomTitlebar"
        android:label="Custom Titlebar"
        android:name=".CustomTitlebar" />
    

    Then define the custom theme somewhere in your resources (for example in res/values/themes.xml):

    <?xml version="1.0" encoding="UTF-8"?>
    <resources
        xmlns:android="http://schemas.android.com/apk/res/android">
        <style
            name="MyCustomTitlebar"
            parent="@android:style/Theme">
            <item
                name="android:windowTitleBackgroundStyle">@style/MyBackground</item>
        </style>
        <style
            name="MyBackground">
            <item
                name="android:background">@drawable/background</item>
        </style>
    </resources>
    

    Since we move the background to the style, we can modify your mytitle.xml layout to the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/myTitle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="custom title bar" />
    

    You might need to adjust either your background (so it has some padding if it’s a 9-patch) or just set the padding in the mytitle.xml layout (using paddingLeft/Right/Top/Bottom).

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

Sidebar

Related Questions

I am making a custom helper in mvc 3 and I m using the
I am making a custom page in Facebook, using FBML and JavaScript on a
What is the process behind making custom widgets (using Qt) that don't look...well...ugly? I
I'm following the example posted here for making custom css tooltips. a { color:
Hi im making a custom Textbox i got everty thing working but how do
I am making a custom form object in Django which has an overrided __init__
I'm making a custom event calendar with PHP. I am trying to get the
I'm making a custom control that can be dragged around and it is semi
I'm making a custom error dialog in my WPF app and I want to
I am making a custom control I need to add some default keybindings, microsoft

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.