Where does AppCompat set the actionbar/toolbar?












0















The boilerplate that Android Studio generates creates a style that extends Theme.AppCompat.Light.DarkActionBar. Somehow, this adds an actionbar/toolbar at the top of all my activities.



How does this happen? Where is the bar defined? It's nowhere in the layouts.










share|improve this question























  • what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

    – Dr4ke the b4dass
    Jan 2 at 0:50
















0















The boilerplate that Android Studio generates creates a style that extends Theme.AppCompat.Light.DarkActionBar. Somehow, this adds an actionbar/toolbar at the top of all my activities.



How does this happen? Where is the bar defined? It's nowhere in the layouts.










share|improve this question























  • what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

    – Dr4ke the b4dass
    Jan 2 at 0:50














0












0








0








The boilerplate that Android Studio generates creates a style that extends Theme.AppCompat.Light.DarkActionBar. Somehow, this adds an actionbar/toolbar at the top of all my activities.



How does this happen? Where is the bar defined? It's nowhere in the layouts.










share|improve this question














The boilerplate that Android Studio generates creates a style that extends Theme.AppCompat.Light.DarkActionBar. Somehow, this adds an actionbar/toolbar at the top of all my activities.



How does this happen? Where is the bar defined? It's nowhere in the layouts.







android android-studio android-layout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 0:36









Danish KhanDanish Khan

5012615




5012615













  • what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

    – Dr4ke the b4dass
    Jan 2 at 0:50



















  • what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

    – Dr4ke the b4dass
    Jan 2 at 0:50

















what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

– Dr4ke the b4dass
Jan 2 at 0:50





what do you mean by defined? If you want to see some implementation code, go in your styles.xml, click on Theme.AppCompat.Light.DarkActionBar to select it, right click, then Go to, then Implementation. You'll see some implementation.

– Dr4ke the b4dass
Jan 2 at 0:50












3 Answers
3






active

oldest

votes


















1














Android studio inflates custom Views or ViewGroups they have already defined, most of these you cannot see because they are private classes.



Here is an example of how you would do this in code.



class Test extends android.support.v7.widget.AppCompatTextView {


public Test(Context context) {
super(context);
initTestView(null);
}

public Test(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initTestView(attrs);
}

public Test(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initTestView(attrs);
}

public void initTestView(AttributeSet as) {
if (as != null) {
TypedArray ta = getContext().obtainStyledAttributes(as, R.styleable.Test);

String textOverride = ta.getString(R.styleable.Test_override);
ta.recycle();

setText("Test: " + textOverride);
}
}

}


Then you would define a styleable in the app/src/main/res/values/attr.xml



<declare-styleable name="Test">
<attr name="override" format="string" />
</declare-styleable>


Now when Android inflates this, it can see your custom class as well as attributes to construct it with. If you were to add this to a layout it would automatically generate an example view of my code. This is the same as Androids core styled Views/ViewGroups and they will oftentimes have default values or visible representations of these class as they are inflated and attached to their parent views.



To make it perfectly clear, when you add an Android View into your layout, let's say for simplicity .



<TextView
android:id="@+id/hello"
android:text="@string/greeting"/>


The class for TextView is doing similar stuff to my examples initTestView method, by grabbing its typed properties (text, id) and populating the Views or values it has internally. It is, at its core, how Android glues xml values to their class representations.






share|improve this answer


























  • "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

    – Danish Khan
    Jan 2 at 0:55











  • Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

    – Chris Sullivan
    Jan 2 at 1:00













  • The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

    – Danish Khan
    Jan 2 at 1:15











  • Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

    – Chris Sullivan
    Jan 2 at 1:21













  • Also updated the answer one last time illustrating the point with a TextView

    – Chris Sullivan
    Jan 2 at 1:26



















0














With the help of Chris Sullivan we figured out what was going on. This is an estimated guess.



It turns out that using the Theme.AppCompat.Light.DarkActionBar style/theme just adds some type top margin to all activities and fills them with the primary color. This makes it look in the Android editor as if there's an app bar/toolbar/action bar, but it's just smoke and mirrors.



The actual app bar is added at runtime by AppCompatActivity.






share|improve this answer































    -1














    This is defined in the styles xml. Your apptheme extends from it. If you want it to be gone you can extend another style for example Theme.AppCompat.Light.NoActionBar






    share|improve this answer
























    • But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

      – Danish Khan
      Jan 2 at 0:43











    • you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

      – PrisonMike
      Jan 2 at 0:44











    • It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

      – PrisonMike
      Jan 2 at 0:45













    • I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

      – Danish Khan
      Jan 2 at 0:49






    • 1





      > Can you define UI components in styles.xml? partially, I will update my code example.

      – Chris Sullivan
      Jan 2 at 1:01











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000059%2fwhere-does-appcompat-set-the-actionbar-toolbar%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Android studio inflates custom Views or ViewGroups they have already defined, most of these you cannot see because they are private classes.



    Here is an example of how you would do this in code.



    class Test extends android.support.v7.widget.AppCompatTextView {


    public Test(Context context) {
    super(context);
    initTestView(null);
    }

    public Test(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    initTestView(attrs);
    }

    public Test(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initTestView(attrs);
    }

    public void initTestView(AttributeSet as) {
    if (as != null) {
    TypedArray ta = getContext().obtainStyledAttributes(as, R.styleable.Test);

    String textOverride = ta.getString(R.styleable.Test_override);
    ta.recycle();

    setText("Test: " + textOverride);
    }
    }

    }


    Then you would define a styleable in the app/src/main/res/values/attr.xml



    <declare-styleable name="Test">
    <attr name="override" format="string" />
    </declare-styleable>


    Now when Android inflates this, it can see your custom class as well as attributes to construct it with. If you were to add this to a layout it would automatically generate an example view of my code. This is the same as Androids core styled Views/ViewGroups and they will oftentimes have default values or visible representations of these class as they are inflated and attached to their parent views.



    To make it perfectly clear, when you add an Android View into your layout, let's say for simplicity .



    <TextView
    android:id="@+id/hello"
    android:text="@string/greeting"/>


    The class for TextView is doing similar stuff to my examples initTestView method, by grabbing its typed properties (text, id) and populating the Views or values it has internally. It is, at its core, how Android glues xml values to their class representations.






    share|improve this answer


























    • "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

      – Danish Khan
      Jan 2 at 0:55











    • Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

      – Chris Sullivan
      Jan 2 at 1:00













    • The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

      – Danish Khan
      Jan 2 at 1:15











    • Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

      – Chris Sullivan
      Jan 2 at 1:21













    • Also updated the answer one last time illustrating the point with a TextView

      – Chris Sullivan
      Jan 2 at 1:26
















    1














    Android studio inflates custom Views or ViewGroups they have already defined, most of these you cannot see because they are private classes.



    Here is an example of how you would do this in code.



    class Test extends android.support.v7.widget.AppCompatTextView {


    public Test(Context context) {
    super(context);
    initTestView(null);
    }

    public Test(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    initTestView(attrs);
    }

    public Test(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initTestView(attrs);
    }

    public void initTestView(AttributeSet as) {
    if (as != null) {
    TypedArray ta = getContext().obtainStyledAttributes(as, R.styleable.Test);

    String textOverride = ta.getString(R.styleable.Test_override);
    ta.recycle();

    setText("Test: " + textOverride);
    }
    }

    }


    Then you would define a styleable in the app/src/main/res/values/attr.xml



    <declare-styleable name="Test">
    <attr name="override" format="string" />
    </declare-styleable>


    Now when Android inflates this, it can see your custom class as well as attributes to construct it with. If you were to add this to a layout it would automatically generate an example view of my code. This is the same as Androids core styled Views/ViewGroups and they will oftentimes have default values or visible representations of these class as they are inflated and attached to their parent views.



    To make it perfectly clear, when you add an Android View into your layout, let's say for simplicity .



    <TextView
    android:id="@+id/hello"
    android:text="@string/greeting"/>


    The class for TextView is doing similar stuff to my examples initTestView method, by grabbing its typed properties (text, id) and populating the Views or values it has internally. It is, at its core, how Android glues xml values to their class representations.






    share|improve this answer


























    • "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

      – Danish Khan
      Jan 2 at 0:55











    • Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

      – Chris Sullivan
      Jan 2 at 1:00













    • The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

      – Danish Khan
      Jan 2 at 1:15











    • Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

      – Chris Sullivan
      Jan 2 at 1:21













    • Also updated the answer one last time illustrating the point with a TextView

      – Chris Sullivan
      Jan 2 at 1:26














    1












    1








    1







    Android studio inflates custom Views or ViewGroups they have already defined, most of these you cannot see because they are private classes.



    Here is an example of how you would do this in code.



    class Test extends android.support.v7.widget.AppCompatTextView {


    public Test(Context context) {
    super(context);
    initTestView(null);
    }

    public Test(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    initTestView(attrs);
    }

    public Test(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initTestView(attrs);
    }

    public void initTestView(AttributeSet as) {
    if (as != null) {
    TypedArray ta = getContext().obtainStyledAttributes(as, R.styleable.Test);

    String textOverride = ta.getString(R.styleable.Test_override);
    ta.recycle();

    setText("Test: " + textOverride);
    }
    }

    }


    Then you would define a styleable in the app/src/main/res/values/attr.xml



    <declare-styleable name="Test">
    <attr name="override" format="string" />
    </declare-styleable>


    Now when Android inflates this, it can see your custom class as well as attributes to construct it with. If you were to add this to a layout it would automatically generate an example view of my code. This is the same as Androids core styled Views/ViewGroups and they will oftentimes have default values or visible representations of these class as they are inflated and attached to their parent views.



    To make it perfectly clear, when you add an Android View into your layout, let's say for simplicity .



    <TextView
    android:id="@+id/hello"
    android:text="@string/greeting"/>


    The class for TextView is doing similar stuff to my examples initTestView method, by grabbing its typed properties (text, id) and populating the Views or values it has internally. It is, at its core, how Android glues xml values to their class representations.






    share|improve this answer















    Android studio inflates custom Views or ViewGroups they have already defined, most of these you cannot see because they are private classes.



    Here is an example of how you would do this in code.



    class Test extends android.support.v7.widget.AppCompatTextView {


    public Test(Context context) {
    super(context);
    initTestView(null);
    }

    public Test(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    initTestView(attrs);
    }

    public Test(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initTestView(attrs);
    }

    public void initTestView(AttributeSet as) {
    if (as != null) {
    TypedArray ta = getContext().obtainStyledAttributes(as, R.styleable.Test);

    String textOverride = ta.getString(R.styleable.Test_override);
    ta.recycle();

    setText("Test: " + textOverride);
    }
    }

    }


    Then you would define a styleable in the app/src/main/res/values/attr.xml



    <declare-styleable name="Test">
    <attr name="override" format="string" />
    </declare-styleable>


    Now when Android inflates this, it can see your custom class as well as attributes to construct it with. If you were to add this to a layout it would automatically generate an example view of my code. This is the same as Androids core styled Views/ViewGroups and they will oftentimes have default values or visible representations of these class as they are inflated and attached to their parent views.



    To make it perfectly clear, when you add an Android View into your layout, let's say for simplicity .



    <TextView
    android:id="@+id/hello"
    android:text="@string/greeting"/>


    The class for TextView is doing similar stuff to my examples initTestView method, by grabbing its typed properties (text, id) and populating the Views or values it has internally. It is, at its core, how Android glues xml values to their class representations.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 2 at 1:24

























    answered Jan 2 at 0:51









    Chris SullivanChris Sullivan

    55658




    55658













    • "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

      – Danish Khan
      Jan 2 at 0:55











    • Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

      – Chris Sullivan
      Jan 2 at 1:00













    • The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

      – Danish Khan
      Jan 2 at 1:15











    • Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

      – Chris Sullivan
      Jan 2 at 1:21













    • Also updated the answer one last time illustrating the point with a TextView

      – Chris Sullivan
      Jan 2 at 1:26



















    • "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

      – Danish Khan
      Jan 2 at 0:55











    • Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

      – Chris Sullivan
      Jan 2 at 1:00













    • The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

      – Danish Khan
      Jan 2 at 1:15











    • Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

      – Chris Sullivan
      Jan 2 at 1:21













    • Also updated the answer one last time illustrating the point with a TextView

      – Chris Sullivan
      Jan 2 at 1:26

















    "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

    – Danish Khan
    Jan 2 at 0:55





    "The bar is defined in an already generated android style", that's exactly my question, how is the style.xml adding a bar to my activity... I know how to remove it, thanks.

    – Danish Khan
    Jan 2 at 0:55













    Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

    – Chris Sullivan
    Jan 2 at 1:00







    Its inflated by android automatically and populated. As part of the build process Android generates R classes as well as pulls in styled components that their appcompat library uses. This can include custom Views or Viewgroups that are only visible to Android (i.e. private classes). Some of the code you cannot see, but if you want a close approximation for whats going on play with the newer appCompat Toolbar class.

    – Chris Sullivan
    Jan 2 at 1:00















    The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

    – Danish Khan
    Jan 2 at 1:15





    The latest edit is starting to make more sense :) But I'm still not clear on something, in your example, I would need to add <Test> to my layout for it to be inflated and shown in the "Design" tab in Android Studio, but I never did this with the toolbar that gets added as part of AppCompat :/

    – Danish Khan
    Jan 2 at 1:15













    Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

    – Chris Sullivan
    Jan 2 at 1:21







    Yes, but its the same principle. Adding <android.whatever.path.ActionBar> does exactly the same thing as my example you just can't see the exposed class.

    – Chris Sullivan
    Jan 2 at 1:21















    Also updated the answer one last time illustrating the point with a TextView

    – Chris Sullivan
    Jan 2 at 1:26





    Also updated the answer one last time illustrating the point with a TextView

    – Chris Sullivan
    Jan 2 at 1:26













    0














    With the help of Chris Sullivan we figured out what was going on. This is an estimated guess.



    It turns out that using the Theme.AppCompat.Light.DarkActionBar style/theme just adds some type top margin to all activities and fills them with the primary color. This makes it look in the Android editor as if there's an app bar/toolbar/action bar, but it's just smoke and mirrors.



    The actual app bar is added at runtime by AppCompatActivity.






    share|improve this answer




























      0














      With the help of Chris Sullivan we figured out what was going on. This is an estimated guess.



      It turns out that using the Theme.AppCompat.Light.DarkActionBar style/theme just adds some type top margin to all activities and fills them with the primary color. This makes it look in the Android editor as if there's an app bar/toolbar/action bar, but it's just smoke and mirrors.



      The actual app bar is added at runtime by AppCompatActivity.






      share|improve this answer


























        0












        0








        0







        With the help of Chris Sullivan we figured out what was going on. This is an estimated guess.



        It turns out that using the Theme.AppCompat.Light.DarkActionBar style/theme just adds some type top margin to all activities and fills them with the primary color. This makes it look in the Android editor as if there's an app bar/toolbar/action bar, but it's just smoke and mirrors.



        The actual app bar is added at runtime by AppCompatActivity.






        share|improve this answer













        With the help of Chris Sullivan we figured out what was going on. This is an estimated guess.



        It turns out that using the Theme.AppCompat.Light.DarkActionBar style/theme just adds some type top margin to all activities and fills them with the primary color. This makes it look in the Android editor as if there's an app bar/toolbar/action bar, but it's just smoke and mirrors.



        The actual app bar is added at runtime by AppCompatActivity.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 2 at 9:17









        Danish KhanDanish Khan

        5012615




        5012615























            -1














            This is defined in the styles xml. Your apptheme extends from it. If you want it to be gone you can extend another style for example Theme.AppCompat.Light.NoActionBar






            share|improve this answer
























            • But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

              – Danish Khan
              Jan 2 at 0:43











            • you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

              – PrisonMike
              Jan 2 at 0:44











            • It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

              – PrisonMike
              Jan 2 at 0:45













            • I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

              – Danish Khan
              Jan 2 at 0:49






            • 1





              > Can you define UI components in styles.xml? partially, I will update my code example.

              – Chris Sullivan
              Jan 2 at 1:01
















            -1














            This is defined in the styles xml. Your apptheme extends from it. If you want it to be gone you can extend another style for example Theme.AppCompat.Light.NoActionBar






            share|improve this answer
























            • But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

              – Danish Khan
              Jan 2 at 0:43











            • you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

              – PrisonMike
              Jan 2 at 0:44











            • It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

              – PrisonMike
              Jan 2 at 0:45













            • I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

              – Danish Khan
              Jan 2 at 0:49






            • 1





              > Can you define UI components in styles.xml? partially, I will update my code example.

              – Chris Sullivan
              Jan 2 at 1:01














            -1












            -1








            -1







            This is defined in the styles xml. Your apptheme extends from it. If you want it to be gone you can extend another style for example Theme.AppCompat.Light.NoActionBar






            share|improve this answer













            This is defined in the styles xml. Your apptheme extends from it. If you want it to be gone you can extend another style for example Theme.AppCompat.Light.NoActionBar







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 at 0:39









            PrisonMikePrisonMike

            94411625




            94411625













            • But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

              – Danish Khan
              Jan 2 at 0:43











            • you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

              – PrisonMike
              Jan 2 at 0:44











            • It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

              – PrisonMike
              Jan 2 at 0:45













            • I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

              – Danish Khan
              Jan 2 at 0:49






            • 1





              > Can you define UI components in styles.xml? partially, I will update my code example.

              – Chris Sullivan
              Jan 2 at 1:01



















            • But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

              – Danish Khan
              Jan 2 at 0:43











            • you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

              – PrisonMike
              Jan 2 at 0:44











            • It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

              – PrisonMike
              Jan 2 at 0:45













            • I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

              – Danish Khan
              Jan 2 at 0:49






            • 1





              > Can you define UI components in styles.xml? partially, I will update my code example.

              – Chris Sullivan
              Jan 2 at 1:01

















            But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

            – Danish Khan
            Jan 2 at 0:43





            But how can you define an actionbar from styles.xml? Shouldn't this be in a layout.xml?

            – Danish Khan
            Jan 2 at 0:43













            you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

            – PrisonMike
            Jan 2 at 0:44





            you create a menu.xml file in the res and use the onCreateOptionsMenu callback in the activity to inflate it

            – PrisonMike
            Jan 2 at 0:44













            It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

            – PrisonMike
            Jan 2 at 0:45







            It is possible to define it in your layout, but then you should use a toolbar and set that as the actionbar in onCreate with the setSupportActionbar method, but i recommend the onCreateOptions menu if you don't need to customize alot

            – PrisonMike
            Jan 2 at 0:45















            I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

            – Danish Khan
            Jan 2 at 0:49





            I know how to define it from code. My question is, how is this placed in my view and displayed in the Android Studio editor without any of this code running and just by adding a theme?

            – Danish Khan
            Jan 2 at 0:49




            1




            1





            > Can you define UI components in styles.xml? partially, I will update my code example.

            – Chris Sullivan
            Jan 2 at 1:01





            > Can you define UI components in styles.xml? partially, I will update my code example.

            – Chris Sullivan
            Jan 2 at 1:01


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000059%2fwhere-does-appcompat-set-the-actionbar-toolbar%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas