why android application logo is not coming in 5.0 version? - android

After updating my device's android version(lollipop), my app's logo is not displaying in lollipop version. and color of action bar has changed.
I am using following theme in my application
android:theme="#android:style/Theme.DeviceDefault.Light"
What would be the issue?

Umm.. that style is follows device's default style.
If you want same style for all devices, set style like this. android:theme="#android:style/Theme.Holo.Light"
Then you can see style with app logo like as before for all devices & versions.
Or if you want Material style. you might be using Toolbar.
http://developer.android.com/reference/android/widget/Toolbar.html

You have to do few changes:
parent="#style/Theme.AppCompat.Light" need to applied in your
style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
</style>
</resources>
And then goto
File->Import (android-sdk\extras\android\support\v7). Choose "appcompat"
then
Project-> properties->Android. Select tab library "Add" and choose "appCompat"

Related

Android define custom style for Menu item

I want to customize text style Android menu item.
I put this to styles.xml
<item name="android:actionMenuTextAppearance">#style/my_custome_actionbar_menu_item</item>
It does not work, but when I remove "android:", it work properly
<item name="actionMenuTextAppearance">#style/my_custome_actionbar_menu_item </item>
Do you know What is different between having "android: " and not?
if you use api7-13,use actionMenuTextAppearance,and if your sdk api>17,use android:actionMenuTextAppearance,maybe the sdk you are using is lower than 17.
I figure out the reason about AppCompat
With new AppCompat-v7 (v21) ActionBar style's properties need to refer to the app namespace, that is without android: prefix.
So,for retro-compatibility, we should use actionBarStyle along with android:actionBarStyle:

Configure Eclipse for Material Design

How do I configure My App to use Material Theme. I don't wanna use Android Studio because its too slow and freezes a lot. I have read the instructions from answer to similar question.
I followed the steps but I didn't get values-21 folder as mentioned in the answer. What can I do now?
There is no difference at project folders structure in this case in Eclipse and AS, maybe you just can't get right preview at Eclipse.
I'm assuming that you currently have a folder res/values that has a file styles.xml which contains your apps theme. Manually create a folder res/values-v21 and copy your styles.xml into it. Modify the new file now so that it uses the material theme as its parent.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="#android:style/Theme.Material">
<!-- Customize your theme here. -->
</style>
</resources>
Now when your app is run on a device/emulator running API 21+ it will use the Material theme.

How to get rid of rendering issue in Android Studio that refers to resource that isn't found in project?

The "Rendering problem" states Couldn't resolve resource #style/Widget.Holo.Actionmode but when I do a project/path search for Widget.Holo.Actionmode it isn't there.
As a result, my soft numeric keypad won't display.
What the heck do I do? I've changed the styles in the Android Studio 1.1.0 dropdown in design mode but no matter what I choose I get the rendering problem and no keypad. I had colors set to Holo this and that because I liked the shades and I had Holo as the theme from the dropdown. I also have in AndroidManifest.xml this:
android:theme ="#style/AppTheme"
But when it was working, I had commented that out to get nice black background. Either way, no keypad.
All I have in styles.xml is this:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.ThemeOverlay.AppCompat">
<!-- Customize your theme here. -->
</style>
</resources>
I exited and re-entered AS. No keypad; same problem.
I'll post all xml and activity java code if need be. This is insane.
Looks to me like there's a problem in APIs 17 & 18 with the definition of Widget.Holo.ActionMode. I added the following to my styles.xml file:
<!-- Put this here to fix rendering error in API 17-18 -->
<style name="Widget.Holo.ActionMode" parent="#android:style/Widget.Holo.ActionMode">
<item name="titleTextStyle">#android:style/TextAppearance.Holo.Widget.ActionMode.Title</item>
<item name="subtitleTextStyle">#android:style/TextAppearance.Holo.Widget.ActionMode.Subtitle</item>
</style>
This may happen on APIs below 17, haven't tested. It was fixed in 19.

Customizing Support Action Bar / Android

I recently started Android programming, all is good and dandy, but I've came across a problem that I couldn't find an answer to, and I really diged hard for 4 days so far.
My app uses support action bar, and to be specific "android.support.v7.app.ActionBarActivity". Long story short, I couldn't handle most of the stuff applicable to an Action Bar to this support one.
My app uses this support action bar by default due to setting up my mini sdk version to 14.
I want to be able to build an action bar from scratch, and customize it, since the default action bar is not responsive to my customization in styles.xml, etc.
I don't mind using Holo theme library instead of AppCompat.
So the question here, how can use Action Bar instead of Support Action Bar?
How can I extend my java class to use that instead of the support one?
Because none of the online customizing solutions are applicable to the support action bar.
A bit foggy description so I apologize for that.
Create a new project, and select the minimum API level as 15. When you do this, the appcompat-v7 library will not be required for this project as it is for projects with minSdkversion < 15. In this project, the classes android.app.ActionBarActivity and android.app.ActionBar will be used by default, i.e. the native AOSP classes and not the ones from the support library.
The following will let you have an ActionBar with custom background color as you want it, on API level 8 and above.
STEP 1. In your res/values folder, define an XML file theme.xml and add the following to it:
<resources
xmlns:tools="http://schemas.android.com/tools">
<style name="DefaultActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle" tools:targetApi="11">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarSize" tools:targetApi="11">#dimen/action_bar_wrap_content</item>
<item name="actionBarSize">#dimen/action_bar_wrap_content</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background" tools:targetApi="11">#color/actionbarbgcolor</item>
<item name="background">#color/actionbarbgcolor</item>
<item name="android:height" tools:targetApi="11">#dimen/action_bar_wrap_content</item>
<item name="height">#dimen/action_bar_wrap_content</item>
</style>
</resources>
In the same folder make another XML file colors.xml and add the following to it:
<resources>
<color
name="actionbarbgcolor">#00FF00
</color>
</resources>
and to the existing file dimens.xml, add the last line:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- Optional, in case you wish to increase the default width of the Action Bar. -->
<dimen name="action_bar_wrap_content">55dp</dimen>
</resources>
In place of #00FF00 above, use the hex color code for the background color you wish to use in your ActionBar.
NOTE: The above will work assuming you are using the appcompat-v7 library. If not, then you'll have to use one of the Holo.Light themes instead of AppCompat.Light, and there will be other changes as well.
STEP 2. In your manifest file, you must add:
android:theme="#style/DefaultActionBarTheme"
to every <activity declaration if that Activity has the ActionBar.
Try this. It will work.
Zygotelnit answer works but you have to omit the ["tools:targetApi="11"] from item declaration otherwise it will give you an error for some reason.
On the other hand, I've found a much shorter and easier but not so optimized solution.While searching through the actionBar class and playing around here is the answer:
In your activity.java, go down to
protected void onCreate(Bundle savedInstanceState)
Anywhere appropriate in that method, write the following code:
ActionBar actionBar = getSupportActionBar();
actionBar.setBackgroundDrawable(new
ColorDrawable(Color.parseColor("#D62D20")));
You replace the color code by any color code of your choosing. It's obviously a hex color code.

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.

Categories

Resources