2015-05-11 24 views
0

我正在使用AppCompatActivity和ActionBar風格@style/Widget.AppCompat.Light.ActionBar。當我從活動創建菜單時,如果設備沒有硬件菜單按鈕,則會在ActionBar中出現溢出菜單按鈕。 但是,在小米紅米Note設備上,溢出按鈕apear在ActionBar中,並且設備擁有自己的硬件按鈕。 這是一些CONFIGS:AppCompatActivity操作欄和設備菜單按鈕

compileSdkVersion 22 
buildToolsVersion "22.0.1" 

defaultConfig { 
    minSdkVersion 10 
    targetSdkVersion 22 
} 
+0

溢出菜單按鈕,會出現設備是否具有硬件菜單按鈕與否。我有一個Galaxy Note 3和Galaxy Note 10.1 2014 Ed,他們都顯示了從版本22(我認爲)compat庫開始的溢出按鈕。 – hfann

回答

1

的程序兼容性-V7支持庫力溢出菜單是在與奇巧和更高的每一個設備的操作欄(或工具欄)始終可見。 MENU鍵(如果存在)仍然可以工作,打開溢出菜單。這是一種理想的行爲,其設計就是這樣。

的代碼非常簡單:

public boolean showsOverflowMenuButton() { 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 
     return true; 
    } else { 
     return !ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(mContext)); 
    } 
} 

你可以看到完整的源代碼在這裏: https://github.com/android/platform_frameworks_support/blob/master/v7/appcompat/src/android/support/v7/internal/view/ActionBarPolicy.java#L49-L55

+0

謝謝。我認爲這是錯誤) – user3867407