Actionbar Issue - android

I want custome actionbar so i edited values-v14/style.xml
Here is what i change in xml file
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<item name="android:height">60dp</item>
</style>
this is my java code where i enabled drawer icon
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayShowTitleEnabled(true);
Now I run on 4.2 and Up device its fine But when i run 4.1 device it's show back icon not drawer icon any answer must be appreciated.
you can see drawer icon replaced with back
Hear is image of 4.4.4 Device you can check and please help me

In your style.xml
<style name="Theme.mytheme" parent="android:Theme.Holo">
<item name="android:homeAsUpIndicator">#drawable/your_icon</item>
</style>
add any icon you want. Icon mostly depends on Device API level.

Your ask is not clear, however... if i understand, you have an application that runs well on 4.2 devices showing drawer icon on left side (drawer menu navigation i suppose). The same application on 4.1 devices doesn't show drawer icon but back icon.
Be sure that your style.xml is correct.
Note that values-v11/style.xml is for API 11+
For API 14+ you must use values-v14/style.xml is for API 14+
You can try to add a new folder to your project values-v19/style.xml for API 19+ Android 4.4
Look in Android Official API Guides -> App Resources -> Style for more details.
And as last I give you two links resources:
To create ActionBars: http://jgilfelt.github.com/android-actionbarstylegenerator/
Useful tools can be found here: http://romannurik.github.io/AndroidAssetStudio/index.html

Related

Show both logo and app name in action bar android

i have set these two lines of code to display both logo and app name in action bar, but only app name appears, like in the screenshot:
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);
Do i need other code to show both? I have added this in manifest but same result:
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:logo="#drawable/icon"
I'm working on a Tabbed activity with action bar.
Can you help me? Thank you
Solved adding
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.icona);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Using logo in actionbar is disabled by default in Android 5.0 Lollipop.
Add these 3 lines in the onCreate(Bundle) method of your Activity class:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher4);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Try this one in your style.xml:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">#drawable/logo</item>
<item name="logo">#drawable/logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
</style>
Don't know whether this makes problems with high api levels but worked for me on API 10.
Did you run you app in emulator or real device? I think on the Design page in the fragment does not show the icon of the app when using the layout of API L or 21.(as show below)
But when you change to API 19 or inflate the fragment into tap, it shows.(as show below)

Dark ActionBar in Holo Dark

I am developing an Android app on Android Studio and I would like to use the Holo Dark theme but in the KitKat version, I mean, how it appears on the picture I attach below.
I'm testing the app on a KitKat AVD, and in the manifest the maximum and target SDK version is 19, but the action bar is like in the pic below:
I just want to get the design like in the first image, so if anyone knows how, please tell me.
You have to use the Solid ActionBar:
<style name="Theme.Whatever" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#android:style/Widget.Holo.ActionBar.Solid</item>
</style>

how to get menu options in android api level 17 devices?

I am having an application which contains Menu options, but in some of Jelly Bean devices we don`t have the Menu soft key button so in that case how can I show those menu options?
Do I need to check sdk version, based on which I have to implement functionality?
and I am unable to use hasPermanentMenuKey() function in my app.
My app targets
android:minSdkVersion="9"
android:targetSdkVersion="17"
Can anyone give me any suggestions?
I think, you must have given android-9 specific theme in Android Manifest.
Example
android:theme="#android:style/Theme.Light"
1) Since Android 4.0 we have Action Bar, so many of the device running Android 4.0 and above will not have Hardware Menu.
2) All your Menu will be in action bar.
3) So, you need to specify different theme to Android v-14 and above, for you app to display Action bar with your menu.otherwise you will not get Action bar so as you Menu.
How To Do It
1) In values/styles.xml
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"> </style>
</resources>
2) In values-v14/styles.xml
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>
</resources>
3) In AndroidManifest.xml
android:theme="#style/AppTheme"
use a lower minSDKVersion. Then in those set there will be a soft key for option menu too. for example
android:minSdkVersion="5"
Since the ActionBar was introduced in HoneyComb the menu you set using the onCreateOptionsMenu is displayed on the ActionBar of the activity.If you specify the android:showAsAction="never|withText" the item goes into the overflow menu...something which looks like three dots and is displayed with it's full text.
You can use the same API you use in pre HoneyComb:
boolean onCreateOptionsMenu(Menu menu)
boolean onOptionsItemSelected(MenuItem item)

How to remove Menu Option in Android 4.2.2

My Android App has min sdk and target sdk set to 10, when I run my app on Nexus 4 -Android Version 4.2.2, it shows a menu option button beside the system navigation.
I am not using menu options in my app and I dont want to show the user this useless menu option. How can I remove it ?
I have read about this on http://android-developers.blogspot.com.au/2012/01/say-goodbye-to-menu-button.html but I do not get a concrete solution.
Attached is the image :
I dont want to change the sdk version for my app. Is it possible to remove menu option without changing sdk version?
You simply have to modify your targetSdk to something above 10. For instance, if you use last SDK you should use targetSdk=16
The concrete solution is in the article:
Add theme to your application:
<application android:theme="#style/NoActionBar">
Then define this theme for pre-Honeycomb in res/values/themes.xml:
<resources>
<style name="NoActionBar" parent="#android:style/Theme">
<!-- Inherits the default theme for pre-HC (no action bar) -->
</style>
</resources>
and for Honeycomb and later:
<resources>
<style name="NoActionBar" parent="#android:style/Theme.Holo.NoActionBar">
<!-- Inherits the Holo theme with no action bar; no other styles needed. -->
</style>
</resources>
If you set your target SDK version to 11 and below, the android legacy menu button will appear. But just in case you want to keep that target SDK version, you can just delete the method onCreateOptionsMenu, this way you won't inflate any options.

Android custom theme on 2.3, holo theme on 4.0

I read http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html but have some issues. For pre-honeycomb I want a custom title, for post-honeycomb I want the default. When I try to run my app on ICS
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
If I remove the custom title it works fine on all releases, just without the custom title.
in values-v11 I have themes.xml file with this content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="customTheme" parent="android:Theme.Holo.Light">
</style>
</resources>
So my theme document says to use no custom theme basically.
If I remove
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
then the theme shows up correctly on ICS.
I cannot imagine that I have to check on coding level what API level I run and either request the window feature or not, that should be handled by the system.
Thanks, A.
Pretty similar to this question. I guess the action bar is considered a title feature, so turning it off gets rid of the exception.
I'm still a bit confused by the question though. You say you want the default title for post-honeycomb, but you can't use a custom title and also use the default actionbar. If you really want to do what you're asking (custom title for < 3.0, default actionbar for >= 3.0), then you'll need to check Build.VERSION.SDK_INT before calling window.requestFeature etc. That's how it's done in the actionBarCompat example that does just this sort of thing.

Categories

Resources