私のアプリケーション用のカスタムタイトルバーを設計しました。それは私にとってもうまくいく。しかし問題がある。カスタムタイトルバーが上書きされる前に、デフォルトのタイトルが表示されます(数秒間)。アンドロイドが提供するデフォルトのタイトルバーを無効にする方法はありますか?androidのカスタムタイトルでデフォルトのタイトルを上書きする方法
私のコードは、/解像度で
window_title.xml /レイアウト解像度で
<?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 ...のようだったのres /値の
<?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値
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="titlebackgroundcolor">#303010</color>
<color name="titletextcolor">#FFFF00</color>
</resources>
themes.x解像度でミリリットル../
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="WindowTitleBackground">
<item name="android:background">@color/titlebackgroundcolor</item>
</style>
</resources>
値と私はまた、
<?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>
と私が好きやった私のonCreateメソッドのように、私のmanifest.xmlの活動を更新した
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");
そして、これもうまくいく
http://www.edumobile.org/android/android-programming-tutorials/creating-a-custom-title-bar/
でコード化されていて、うまくいきますあまりにも..
最初に来るデフォルトのタイトルを無効にする方法はありますか?あなたはちょうどあなたが好きなあなたのタイトルバーを設計し、あなたの主なレイアウトでトップでそれを設定し、ここではレイアウト
requestWindowFeature(Window.FEATURE_NO_TITLE);
を設定する前のonCreateに次のコードを使用し、タイトルバーのためにAndroid上で中継する理由
だけでランダムな思考を持って願っています..........テーマを設定し、その他の機能や権限を設定するようなあなたのタイトルバーのための他の任意のものを設定する必要がいけませんあなたはonCreateメソッドの最後の行として "setContentView"を配置しようとしましたか? –
この行を変更しない場合はカスタムタイトルを書く必要があります。android:text = "カスタムタイトルバー"をandroid:text = "" –
@STT LCU&user370305:私はすでに試していました。私はgetWindow()のようにコーディングしていますが、setFeatureInt(Window.FEATURE_CUSTOM_TITLE、R.layout.window_title); setContentView(R.layout.main);エラーが表示されます。しかし、私が質問したようにそれを置くと、それはうまく動作します –