I am trying to display a permanent small logo on the left size of the ActionBar, but I can't find how to do so. Please help me find a solution.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.redislabs.app.redis.infoIntent">
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
There is a place to Specify your Logo in the
<application>
tag. This is located in your Manifest.xml file for your app. The value should be set to locate a drawable resource.
<application
android:logo="drawable resource">
I hope this helps!
Happy Coding! Leave a comment if you have any questions.
Related
i am trying to mage a lollipop app and solved my problems with tabs and style problems, but now i got a error i didn't see before and got no solution by other posts. i don't really know what happens there.
also i am using stack overflow first time to ask a question and i don't really know what all of my code u need for this issue.
thats my
menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<item
android:id="#+id/action_share"
android:title="#string/share"
android:orderInCategory="99"
app:showAsAction="always"
android:icon="#android:drawable/ic_menu_share"/>
<item
android:id="#+id/action_settings"
android:title="#string/action_settings"
android:orderInCategory="100"
app:showAsAction="never"/>
see this pastebin for the error
Seems that this doesn't exist:
android:icon="#android:drawable/ic_menu_share"/>
Are you sure that this exists? You could copy that drawable in your drawable folder and use
android:icon="#drawable/ic_menu_share"/>
instead.
I am following step by step instructions shared on development platform of google http://developer.android.com/training/basics/actionbar/index.html
But some how due to some reason I am not seeing ic_action_search.png on Menu bar in my simulator, though it is imported and copied on drawable-hdpi.
Listing down all options tried till now (using eclipse IDE):
Import image ic_action_search.png
Don't import image but copy it directly on folder
Size of image, I have copied it directly from Android_Design_Icons.zip suggested at https://developer.android.com/design/downloads/index.html
Recompile project by "Clean"
Deleting res in bin folder
Deleting R.java in gen folder
Creating whole project altogether again
Changing option android:showAsAction to "never", "always", "ifRoom"
Placing .png file at right place
Not using .jpg only .png
Using Support library
Using lower case to define file names
Added following to menu tag,
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.actionbar.MainActivity"
Added follwoing to item tag
android:actionViewClass="android.widget.SearchView"
My main_activity_actions.xml looks like,
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="never" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" /></menu>
.... but still I cant see search image getting loaded up in menu bar. Though settings icon shows the action_search value defined in string.xml
I am not using Support Library Setup as of now, and android:minSdkVersion="11"
android:targetSdkVersion="19"
I need to show this, as there is something wrong here and as i go further I still cant load any other image. Please advise
You need to change the showAsAction as always or ifRoom to show the action icons in the menu bar.
If you set it to never , it will not be shown as an action menu. It will only show in PopupMenu
Change
android:showAsAction="never"
to
android:showAsAction="always"
append this line in your menu tag xmlns:yourapp="http://schemas.android.com/apk/res-auto"
and append these two lines in item tag
yourapp:actionViewClass="android.widget.SearchView"
yourapp:showAsAction="always"
i.e. use this layout
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<!-- Search / will display always -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:actionViewClass="android.widget.SearchView"
yourapp:actionViewClass="android.widget.SearchView"
yourapp:showAsAction="always"
android:showAsAction="always"/>
I have a problem: I want to put a search Icon on the Action Bar. In Android Studio it shows it on the Action Bar, but when I open the App it only shows it in the menu..
Here is my xml code:
<item
android:id="#+id/action_settings"
android:title="#string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
<item
android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:showAsAction="ifRoom"
android:title="#string/action_search"/>
I tried many things but it wont work. I hope you can help me.
It still doesn't work I really don't have a clue why.
You're not specifying your ActionView class, which is probably part of the problem. Here is the xml for a search action view that I use in one of my applications that works fine.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/search_user"
android:actionViewClass="android.widget.SearchView"
android:icon="#drawable/magnifing_glass"
android:showAsAction="ifRoom|collapseActionView"
android:title="#string/action_search"/>
</menu>
EDIT:
If you're not trying to use it as an ActionView, disregard the above and use showAsAction="always".
Your problem is either that there is not enough space on the action bar to display the icon, or your device has a dedicated menu button.
All, Forgive me I just began to learn development of Android, It is the first time I used the ActionBar in my Android application. Firstly.
I was following the tutorial to add the resource of ActionBar to project. But the IDE alert me the resource can't be found. please help to review my current setup. thanks.
I had downloaded and upziped all the Icons. and copy all the icons under the res/drawable folder.
and I add a xml file named main_activity_actions.xml under the folder res/menu which content shows below.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/Core_Icons/unstyled/hdpi/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
</menu>
Could someone please tell me why IDE can't find the icon ic_action_search.png? thanks.
Unfortunately the resource folders do not support directory hierarchies (sub-folders), so you will need to move all icons to the parent folder (drawable).
Then reference it like this: android:icon="#drawable/ic_action_search"
https://code.google.com/p/android/issues/detail?id=2018
Here is my XML
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/refresh" android:title="Home"
android:icon="#drawable/menu_home" />
<item android:id="#+id/search" android:title="Search"
android:icon="#drawable/menu_search" />
<item android:id="#+id/help" android:title="Help" android:icon="#drawable/menu_help" />
</menu>
Icon is getting displayed but title doesn't. Please advise.
I'll post this as an answer then...
The size of menu pixes can be too large (such as 72x72). Make sure you use the proper size icons for your current display.
I had the same problem, but my menu icon size was 32x32. And still displayed over the text. So, I played a little with the sizes, and set it to about 47x47 and it finally worked.
So, if this happens, try to play with the image sizes.