(Android) How to style action bar with pattern [closed]

半世苍凉 提交于 2019-12-29 01:27:30

问题


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!



来源:https://stackoverflow.com/questions/26439715/android-how-to-style-action-bar-with-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!