D
D
dimasik1002002017-11-18 22:32:44
Java
dimasik100200, 2017-11-18 22:32:44

How to solve the problem with ToolBarom?

I'm trying to embed a toolbar in my application so that I can change it later as I see fit. But when it is initialized, the actionbar data still appears.
Here is the styles.xml code

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Here is the code snippet of MainActivity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

Here's what happens when you run the application
5a1089db18667735945141.png
. If you remove the setSupportActionBar(toolbar) line, the toolbar becomes normal, but you can't place anything on it. How can this be fixed?
5a108a54a7408157627526.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-11-19
@zagayevskiy

What do you mean by "can't post"? Of course, you can't refer to him as an action bar, he's just an ordinary wedge group that lives a bit of its own life. It is necessary to call any methods directly on it, such as toolbar.setTitle (). toolbar.getMenu().and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question