frozenhill
frozenhill

Reputation: 124

Custom title bar issue

I set a custom title bar as example http://coderzheaven.com/2011/06/custom-title-bar-in-android/ , every thing works fine but still blue frame appear from original title . The only thing I added is to set the background color to custom title as (android:background="#EECBAD"). How can I remove this blue frame?

###custom_title.xml:

    <RelativeLayout 
     android:id="@+id/RelativeLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="#EECBAD"
     xmlns:android="http://schemas.android.com/apk/res/android">
     <ImageView
     android:layout_width="40dip" 
     android:id="@+id/ImageView01" 
     android:background="@drawable/ic_launcher" 
     android:layout_height="40dip" /> 
    <TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"  
    android:id="@+id/tv" 
    android:text="ELNABIH"
    android:layout_toRightOf="@+id/ImageView01"
    android:textColor="@drawable/red"
    android:textStyle="bold" 
    android:layout_marginLeft="5dip"
    android:layout_marginRight="5dip" />
    </RelativeLayout>

java.class

      package com.test.list;
    import android.app.Activity;
     import android.os.Bundle;
     import android.view.Window;
     import android.widget.TextView;
     public class Tttt extends Activity {  
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
           super.onCreate(savedInstanceState); 
           Boolean customTitleSupported = requestWindowFeature
           (Window.FEATURE_CUSTOM_TITLE); 
           setContentView(R.layout.main);  
           if (customTitleSupported) { 
               getWindow().setFeatureInt
           (Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title); 
               TextView tv = (TextView) findViewById(R.id.tv);  
               tv.setText("name");  


             }
           }
         }

Upvotes: 3

Views: 1475

Answers (5)

Yauraw Gadav
Yauraw Gadav

Reputation: 1746

Brother, I think this link would help you for sure. I think you'll have to define styles and themes in xml too.

Please create styles.xml & themes.xml in values folder folder under res. Write the following code :

Code for styles.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <resources> <style name="WindowTitleBackground" parent="android:Theme"> 
    <item   name="android:background">@android:color/background_dark</item>
    </style>
    </resources>

Code for themes.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <style name="MyTheme" parent="android:Theme">
    <item name="android:windowTitleSize">54px</item>
    <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>                 
    </style>
    </resources>  

and insert this in your manifest - android:theme="@style/MyTheme"

Upvotes: 1

dcanh121
dcanh121

Reputation: 4695

You should hide the default title first. You should declare that in AndroidManifest.xml for the activity or set the window params in the java code.

<activity 
    android:name=".MainActivity" 
    android:theme="@android:style/Theme.Black.NoTitleBar" />

Upvotes: 0

Namor Alves
Namor Alves

Reputation: 143

put on style.xml:

<style name="CustomWindowTitleBackground">
        <item name="android:background">@color/LightFacebook</item>
    </style>

on @color/LightFacebook use u custom color.

Upvotes: 1

Adinia
Adinia

Reputation: 3731

If you set the background color for tv TextView, it's because it also has some right and left padding, beside being set to wrap_content:

android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"

You can remove those lines, or try to set the background color for the parent, RelativeLayout01

Upvotes: 1

akarimova
akarimova

Reputation: 200

Try to override "android:windowTitleBackgroundStyle".

Upvotes: 1

Related Questions