Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Capturing Photos and Videos Adding a Camera Button in the Action Bar

Camera icon not showing up

The camera icon just won't show up on the action bar. It does in the overflow menu but only as "Camera" that's it. Here is my <item/> code

'''xml

   <item android:id="@+id/menu_camera"
    android:title="@string/menu_camera_label"
    android:icon="@mipmap/ic_camera_white_18dp"
    android:showAsAction="ifRoom" />

'''

7 Answers

Arthur Dejardin
Arthur Dejardin
6,451 Points

To anyone facing the same problem: I solved it by having app:showAsAction="always" instead of android:showAsAction="always" in the menu_main.xml

Cheers, Arthur

Hi, I'm having the same problem: its showing up in the overflow menu even after i added android:showAsAction="always".

    <item android:id="@+id/menu_camera"
          android:title="@string/menu_camera_text"
          android:icon="@mipmap/ic_action_camera"
          android:showAsAction="always"/>

Help please.

Never mind I figured it out: It should be: app:showAsAction="always" because of the: xmlns:app="http://schemas.android.com/apk/res-auto" which includes the support library.

Eleni Minadaki
Eleni Minadaki
3,687 Points

Hi Alex.i am so sorry i haven't done yet that lesson. Hope find it soon!

It's alright, Please tell me when you do.

Arthur Dejardin
Arthur Dejardin
6,451 Points

Hi guys,

Same problem here ! Anyone got it working?

Thx, Arthur

Joshua Douce
Joshua Douce
13,120 Points

Had the same problem thanks for the answer Arthur

amir baldiga
amir baldiga
2,530 Points

problem Solved!!!

add: menu.add(0, 0, 0, "androidDemo").setIcon(R.drawable.ic_action_camera);

to: public boolean onCreateOptionsMenu(Menu menu) {

Andre Colares
Andre Colares
5,437 Points

Here is the main.xml for correct function at Android Studio 1.4

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:yourapp="http://schemas.android.com/apk/res-auto">

    <item android:id="@+id/action_edit_friends"
          android:title="@string/menu_edit_friends_label"></item>

    <item android:id="@+id/action_logout"
          android:title="@string/menu_logout_label"></item>

    <item android:id="@+id/action_camera"
          android:icon="@drawable/ic_action_camera"
          android:title="@string/menu_camera_label"
          yourapp:showAsAction="ifRoom"
          ></item>

</menu>