Adding an action bar to Theme.Black.NoTitleBar Android

前端 未结 3 397
孤城傲影
孤城傲影 2020-12-10 08:36

I\'m trying to add the action bar programatically as shown in the dev documentaion but I\'m coming across an error. My minSdk is set to 11, my application has one layout and

3条回答
  •  感动是毒
    2020-12-10 09:39

    What Darshan Said ... kind of

    To go a little further I would check out ActionBarSherlock, in combination with the support library you can then add the action bar to pretty much any version of android that is 2.x+

    To get a full screen / no title bar you would create your own theme from one of the ABS theme's similar to

    
    

    Applying that theme in your onCreate and then getting the action bar to show is the same (except you would use the ABS support prefix ) so basically

    setTheme(R.style.Theme_MY_Sherlock_Fullscreen);
    setContentView(R.layout.mylayout);
    getSupportActionBar.Show();
    

    I am assuming you can do the same for a standard action bar (using the holo theme as a base) since ABS is pretty much a duplicate functionality wise (and much of the source, ABS is mostly a wrapper class) it even detects and then uses the native implementation on 14 and above (11 and in-between has some missing features / fixes )

    You can take a look at ABS here and it looks like he just updated it to JB

    -- In your resources folder under values create a themes.xml file ( /res/values/themes.xml )

    Then put this in there and give the above a try, but of course in setTheme( replace the name with Theme_My_Holo_FullScreen and dont use the getSupportActionbar(). prefix, I never bother using the native implementation but it should work the same.

    
    
    
    
        
    
    
    

提交回复
热议问题