I developed a custom title bar for my application. This works well for me as well. But there is a problem. The default title is displayed (just for a second) before my custom title bar cancels it. Is there a solution to disable the default title bar that android supports?
My codes were similar ...
window_title.xml in res / layout
<?xml version="1.0" encoding="utf-8"?> <TextView 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:textColor="@color/titletextcolor" android:gravity ="center"/>
color.xml in res / values
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="customTheme" parent="android:Theme"> <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground </item> </style> </resources>
styles.xml in res / values
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="titlebackgroundcolor">#303010</color> <color name="titletextcolor">#FFFF00</color> </resources>
themes.xml in res / values
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="WindowTitleBackground"> <item name="android:background">@color/titlebackgroundcolor</item> </style> </resources>
And I also updated the activity of manifest.xml, like
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.title" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/ic_launcher" android:theme="@style/customTheme" android:label="@string/app_name" > <activity android:name=".CustomTitleActivity" android:theme="@style/customTheme" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
and my onCreate method, which I did as ..
super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.window_title); final TextView myTitle = (TextView) findViewById(R.id.myTitle); myTitle.setText("Converter");
And it works well too
I coded as in http://www.edumobile.org/android/android-programming-tutorials/creating-a-custom-title-bar/ and it works well too.
In any case, disable the default header that appears first?