custom CAB background android - android

Can the background for the CAB (contextual action bar) in android, be changed?
I am using it in my application, and when the application is installed on a tablet (3.0 - 3.2 API) the CAB has a yellow color and one look, and when the application is installed on phone with 4.0+ API it has some kind of blue background and another look.
Can I do sth about this and have the same look everywhere?
note: my application is intended to run on 3.0+ api's

You could do this by defining your own themes. Use one of the standard themes (in your case you can use Theme.Holo since you are targeting Honeycomb+) as a start point and customize (i.e., override) those pieces that you want to change. In your case you would customize just the style for the CAB.
The Styles and Themes section of Android dev site introduces you to this in brief. Two additional places to look for real world example of how this has been done are:
Actionbar Sherlock. Look at the actual library source (rather than the samples).
Google IO 2012 app.

Related

Backward compatibility Material Design

As Google says in this page, Material Theme is only available on Android L Developer Preview.
But how can these apps work on previous version of Android L?
https://play.google.com/store/apps/details?id=com.borggren.notes
http://officialandroid.blogspot.it/2014/10/a-new-look-for-google-play-newsstand.html
There are other apps.
Do they use some components similar to material design?
Don't they use the "android:Theme.Material"?
Or is there a way to use Material Theme on previous versions (and I am the only one who doesn't know how to do this)?
I think they are using the components not the theme itself. If you try to give this theme as your overall theme in studio without the minSDK =21 it gives you an error. They are trying to emulate the material design.
For example if you want the floating action bar you can use this project. https://github.com/FaizMalkani/FloatingActionButton
I guess he uses frame layout to emulate that button on the lower right corner. Have a look!!

Tablet-friendly interface and compatibility in Android development

I want to develop a new Android app. Design guidelines for Droid 3.0+ encourage the use of fragments to create a UI that better utilizes tablets' screen space. Also, from Droid 3.0+ I have read that a menu bar should exist on every activity that has a menu instead of using the plain old menu key
These features are supported by SDK 11+, but I want to support SDK 8 as minimum SDK in order to achieve best market share (see here).
How can I achieve both of my objectives?
You have two possibilities:
Google provide support library for developing apps with using fragments and action bars with support of old android versions.
There is great tool Action Bar Sherlock.

ICS style in Froyo and Gingerbread Apps

I am developing an application for Android and I'm using the API level 8. However I would like this app would use the theme of ICS when running on Froyo and Gingerbread because the theme of the ICS is much more beautiful. I wish that at least the color scheme and shape of the buttons were equal. Is there any way to do this?
The first thing you might want to look at is ActionbarSherlock as it adds a lot of consistency to your pre-ics code, even though this is not directly related to the theme.
Then take a look at the HoloEverywhere project on GitHub for using the Holo theme on apps designed for pre-ics devices.
The best i found is android-holo-colors in which you will get all the controls and also can choose holo-light or holo-dark with custom colors you want.
I hope this will help you
The SDK folder contains most of the themes, styles and drawables used in ICS. Check
SDK folder\platforms\android-15\data\res.
You can apply themes/styles in your app like this

Steps to write better ActionBars in Android

These are my doubts while using ActionBar.
1) To make it prevalent across various tabs, I had to repeat the same code in all the tabs. Is there a better way to rewrite this part? I could have one ActionBar class which I can call everywhere, but that won't make it dynamic. (More options in certain tabs.)
2) I'm presently defining a menu and inflating it. Is it the best way to go about it? The problem I am facing here is I'm definitely not using the entire space and always running out of space to put in more actions. How to rectify it?
3) The third problem that I'm facing is a bug when I use Theme.Light. The app crashes. If I use Theme.Holo.Light, the app doesn't. Though, it still crashes in a 2.3 supporting phone. Anyway to rectify that? I mostly feel that I've missed out on backward compatibility or is Action bar not compatible with certain themes?
This answers your 3rd question, straight from docs here:
Beginning with Android 3.0 (API level 11), the action bar is included in all activities that use the Theme.Holo theme (or one of its descendants), which is the default theme when either the targetSdkVersion or minSdkVersion attribute is set to "11" or greater.
If you want to use ActionBar APIs, such as to add navigation modes and modify action bar styles, you should set the minSdkVersion to "11" or greater. If you want your app to support older versions of Android, there are ways to use a limited set of ActionBar APIs on devices that support API level 11 or higher, while still running on older versions. See the sidebox for information about remaining backward-compatible.
Sidebox info
If you want to provide an action bar in your application and remain compatible with versions of Android older than 3.0, you need to create the action bar in your activity's layout (because the ActionBar class is not available on older versions).
To help you, the Action Bar Compatibility sample app provides an API layer and action bar layout that allows your app to use some of the ActionBar APIs and also support older versions of Android by replacing the traditional title bar with a custom action bar layout.

use holo theme on Android < 4.0

I'm developing an app for Android 2.2 and higher.
I use the great ActionBarSherlock (thank you, Jake Wharton !!) to use the action bar on pre-ICS devices.
While the actionbar looks great, all other gui elements have the look of the default theme of the device (in my case HTC Sense 3).
Is there a possibility to style my (>= Android 2.2) app on all android devices with the Holo.Dark.Theme?
I compile my app with Android 4.0.3, the minSDK version is 8.
Enjoy HoloEverywhere, that's the whole purpose of the project!
(Edit) new adress: https://github.com/Prototik/HoloEverywhere
No. That would require a back port of the complete Holo theme and styling, which Google chose not to do. It would also be a rather ambitious undertaking and I would think it is out of scope of the ActionBarSherlock project, whose focus is on ActionBar compatibility.
The best you can do is cherry pick the resources you most want from the ICS source and create your own custom theme/styles.

Categories

Resources