I noticed that if I use setSupportActionBar on API levels 21 and higher, the toolbar does show up. However, if I press the Settings button, I get a different ActionBar pop up. Am I doing something wrong? So far, I have written a toolbar for android.widget.Toolbar
and am using that instead on devices API level 21 or higher.
After further experimentation, it seems this only occurs on real devices that have a hardware settings button.
So in other words you somehow end up using 2 actionbars.
The only fix I have found is to use setActionBar when appropriate and otherwise use getSupportActionBar.
Right now, I essentially overloaded a layout by creating two duplicate layouts which are platform specific. One targets API 8-20 and one targets 21 and higher. Obviously, the API 8 version uses the supportToolbar while the API 21 version uses android.widget.Toolbar. Then within the activity, I do a runtime check on the build version and cast it to the right toolbar version and set it.
I hope somebody else finds this useful since they were no responses.
How do you have setSupportActionBar override natural actionbar for API 21 and higher?
Post a Reply
Nothing to see here.
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|