I need to style my Android actionbar in similar way (EXAMPLE). I know that this is iOS version and it isn't suits to Android guidelines, but this is my task. I also know I cant change color of status bar, my goal is only to style action bar. I would appreciate for any tips how to do it.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you want to change the ActionBar, create a custom one of your preference.
First create an XML layout on how your custom ActionBar should look like. Here make sure you add an ID to the container layout (Linear Layout). The will be required at the later steps.
Second Inflate the XML layout created in you java code onCreate method as follows,
LinearLayout myTitleBar = (LinearLayout) findViewById(R.id.the_id_you_set_in_first_step);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.name_of_custom_xml_layout); //note that here its the layout name you set
Note: As you are dealing with ActionBar, your application theme should be set to Theme.AppCompat.Light
To learn more about them, have a look at this quick video tutorials demonstrating the same.
Part One - 5min
Second Part - 9min
Third Part
Hope it helps!