在添加自定義操作欄後,我將自定義操作欄添加到自己的活動中,但正確顯示在上方,但默認操作欄仍顯示在自定義操作欄旁邊。請參閱下面的截圖我想刪除黑色行動吧,如果有人知道這個請幫我在這裏當我設置自定義操作欄時,顯示兩個操作欄
I refereed this link to add custom action-bar
請參考下面的截圖我想刪除暗行動吧
please refer this screenshot I want to remove dark action-bar
在添加自定義操作欄後,我將自定義操作欄添加到自己的活動中,但正確顯示在上方,但默認操作欄仍顯示在自定義操作欄旁邊。請參閱下面的截圖我想刪除黑色行動吧,如果有人知道這個請幫我在這裏當我設置自定義操作欄時,顯示兩個操作欄
I refereed this link to add custom action-bar
請參考下面的截圖我想刪除暗行動吧
please refer this screenshot I want to remove dark action-bar
添加到您的styles.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item> <!-- For 2.x version -->
</style>
</resources>
,並使用該主題在你的男人ifest文件
android:theme="@android:style/Theme.AppCompat.Light.NoActionBar"
爲什麼不使用已有的'.NoActionBar'主題? –
你必須讓你的活動主題,在AndroidManifest.xml中RES /價值/ styles.xml
<activity
android:name="YOUR ACTIVITY NAME"
android:theme="@style/AppTheme" />
定式
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
你的解決方案是什麼? –
首先,如果你想作爲初學者的自定義Action Bar,我會推薦使用Toolbar小部件。它用作常規小部件,取代了Action Bar。一旦你把工具欄小工具的佈局,你應該把它作爲支持行動吧,你onCreate
方法:
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
這隻有你使用的AppCompatActivity
作爲活動的基地。如果不是,你將不得不重做它。
你延長AppCompatActivity
代替Activity
後,你應該改變你的主題,到.NoActionBar
版本,如Theme.AppCompat.Light.NoActionBar
,從而使系統本身並不提供一個操作欄,而是使用您所創建的一個(如果你不這樣做,你會得到一個錯誤)。
一旦你完成了這個,它應該工作!
讓您的應用主題從Theme.AppCompat.Light.NoActionBar繼承或Theme.AppCompat.NoActionBar – MidasLefko
Theme.AppCompat.Light.NoActionBar它顯示像那@MidasLefko –
可能的複製[如何設置自定義字體在ActionBar Title?](http://stackoverflow.com/questions/8607707/how-to-set-a-custom-font-in-the-actionbar-title) –