(Android) How to style an action bar with a template

I need to configure the Android action bar in a similar way ( EXAMPLE ). I know that this is a version of iOS, and it is not suitable for Android manuals, but this is my task. I also know that I cannot change the color of the status bar, my goal is only to create an action bar. I would appreciate any advice on how to do this.

+1
source share
1 answer

If you want to change the ActionBar, create a custom one from your preferences.

First, create an XML layout of what your custom ActionBar looks like. Here, make sure that you add the ID to the container layout (Linear Layout). This will be necessary in the subsequent steps.

Second Click the XML layout created in your onCreate java code 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. . Since you are dealing with an ActionBar, your application theme must be installed on Theme.AppCompat.Light

To learn more about them, check out these quick video tutorials that demonstrate the same thing.

Part one - 5 minutes

The second part - 9min

The third part

Hope this helps!

+4
source

Source: https://habr.com/ru/post/1205593/


All Articles