If you create an activity and set a label without disabling the title bar you will see a title that uses a gradient as a background. Is there a way for me to re-use this resource without re-implementing it?
Thanks
I believe the background for this comes from the resource that is called "activity_title_bar.9.png" that is in the system drawable folder.
Here is a copy of it:
If you download it from here you'll have to rename it using the .9.png suffix. You can also find it in your SDK. The path is "SDK\platforms\android-4\data\res\drawable"
Note android-4 could be any other number that you happen to have installed on your machine.
Generally if you are wanting to use a system resource like this best practice is to save your own copy of it and include it in your project. Resources like this are subject to change at any time with new versions of the OS (or even with device specific skins that Manufacturers add on to the OS) So if you rely on the system copy from inside your app then you have no way to know for sure that it will look the same across all devices.
Related
I'm trying to locate the Android XML and drawable files that are used by default for imageButtons.
I'm trying to customise an imageButton using a selector. When I create a new project, by default the background color of an imageButton is transparent-grey and it gets highlighted in blue when touched. (I'm SDK-19 and .Light theme). To avoid the hassles of re-creating lots of icons, I want to find the default XML selector code and 9.pngs Android uses for an imageButton.
Looking in the SDK android-19/data/res/drawable folder there are a bunch of XML selectors defined in files with names like "btn_default_holo_light" "btn_default_transparent" etc., and a bunch of button drawables in .../drawable-hdpi.
I can pick any of these, copy it into a "my_selector.XML" file in my project's drawable folder (plus copy the necessary drawables into my projects drawable_hdpi), and set "my_selector" as my imageButton's background. This all works fine...Except none of the SDK files I've found results in the default "blue when touched" effect (some turn the imageButton orange, others do nothing...).
I'm sure the default files are right there under my nose but I'm pulling my hair out trying to find them!
Any help appreciated
I am afraid you won't find the default images you are looking for in the SDK files. The default images can vary from device to device, rather than from android version to android version. The effect you are looking for is probably specific to your device/emulator.
"The appearance of your button (background image and font) may vary from one device to another, because devices by different manufacturers often have different default styles for input controls."
Reference^^
If you just want to get the images and copy them, you may be able to find them on the actual device by activating USB Debugging and searching through the usually hidden folders on your particular device. The storage of those files probably vary between devices so I am afraid I can't tell you where they are (some files are kept hidden even with Debugging active. In those cases apps such as ES File Explorer might be able to help). Although this probably wasn't the answer you were looking for I hope this helps.
I have a standard aplication. It uses resources - PNGs that are when programming in the DRAWABLE folder. They build up menus, buttons etc etc. ... Classic application nothing special.
And what I need to have is - "theme" support. Lets say I use this PNGs in my app:
menubutton.png
scrollbotton.png
arrwo.png
and these are in the DRAWABLE folder.
And I would like to be able to change the THEME of the app by changing this PNGs for different ones. Lets say I have PNG's with same names, but under a different url:
.../template1/menubutton.png
.../template1/scrollbotton.png
.../template1/arrwo.png
and than I have a another "template"
.../template2/menubutton.png
.../template2/scrollbotton.png
.../template2/arrwo.png
IMPORTANT: Of course all the PNGs have exactly same size, and name
So and the app shall have the functionality to download this PNGs and replace the ones that are currently in use. The important point is that the additonal PNGs from different templates HAVE to be availiable online - I dont want to ship the app with many templates that would not be used.
Can you please confirm this can be done and that it should not be a problem?
The Drawable resources are packaged in to the application and cannot be modified. You idea of using an SD card will work (or you can use the applications sandboxed directory), you just need to manually load the png resources (ex. myImageView.setBackgroundBitmap(...); [pseudo-code]).
As a note: If I ever open an application that immediately tells me to wait since it is downloading resources, I will force-close it and uninstall. Applications on Android, iOS, Windows, etc. should work right away without the need to download more resources. If you want a default "theme" then package it with the app, don't make the user download it (which will cause problems if the user is on mobile networks or doesn't have an internet connection when they open the app)
I want to add a feature on my app to let users give a feedback on data. (for example to report errors or mistakes).
Is there a standard icon for it?
please, visit your android-sdk-* folder, there should be default set of icons and pictures in the ./platforms/android-XX/data/res/drawable-Xdpi/ where "XX" and "X" stand for your android version and screen size. all the standard icons are there.
There are a few system icons whose filenames match 'feedback', but none of them look appropriate to me.
Best I could find is "ic_menu_report_image.png".
I've been using "ic_menu_start_conversation.png".
Whether it’s useful for your app mainly depends on the iconset you’re already using. In a chat-app for example, this icon would be a poor choice :)
Note: this icon is marked as protected. You'll have to copy the images to your source manually.
Because these resources can change between platform versions, you should not reference these icons using the Android platform resource IDs (i.e. menu icons under android.R.drawable). If you want to use any icons or other internal drawable resources, you should store a local copy of those icons or drawables in your application resources, then reference the local copy from your application code. In that way, you can maintain control over the appearance of your icons, even if the system's copy changes.
I am programming an android application and I'd like to use the system icons for mail, phone, calendar and contacts inside this application. The problem is, that these icons differ from system to system (different android versions and different smartphones) and I want to keep the application and the system consistent. Is there an easy way to achieve this?
In XML use default android drawables from #android:drawable/... and in code use android.R.drawable....
You can use the standard drawable using
#android:drawable/[icon_name] in your xml file
android.R.drawable.[icon_name] in your java code
You can see different icon in your file system in
[SDK PATH]/platforms/platforms/[ANDROID_VERSION]/data/res
Some images are standard...like contacts, calendar :)
You can't keep system consistent. For what? New versions of Android are usually prettier than older ones (well, it's my opinion).
The only way to keep system icons same for your app - copy them into your drawables instead of using direct reference to them (like #android:drawable/).
First of all if you intend to use the default images (icons) for mail , phonr etc.
This default can be used as android.R.drawable.name in code or #android:drawable/ in xml from http://docs.since2006.com/android/2.1-drawables.php
But as this will vary from OS versinos to Versions.
So , if you need to use an unique GUI for the app for all versions and devices.
Please do not use android provided images , simply use your own graphics or images supplied in drawables resources explicitly by you for your app.
If you're ok with icons from each system you can get it via PackageManager and getApplicationInfo method.
If you're not, you should copy the resources from the platform into your own application.
I'm trying to use one of Android's spinner drawables (spinner_black_16, spinner_black_20, spinner_black_48, or spinner_black_76) as demonstrated on this page. My project is using SDK 2.1, so I updated it to 2.2 as that page states is the SDK version where these are included. Unfortunately, none of the android.R.drawable.spinner_black_xx appear to be defined.
Are these drawables not available for developer usage? The only other way I seem to be able to access them is via the following convoluted method:
final Drawable spinner = new ProgressBar(context).getIndeterminateDrawable();
Unfortunately, that provides me the white spinner, not the black one.
The best way to access those drawables is to copy them from your SDK directory into your project and then access them like any other resources.
The drawables are located in $ANDROID_SDK_DIR/platforms/android-*/data/res/drawable-*/. You can download and select the version of the OS that you'd like to pull drawables from. API level 7/OS version 2.1 has the full complement:
platforms/android-7/data/res/drawable-mdpi/spinner_black_16.png
platforms/android-7/data/res/drawable-mdpi/spinner_black_20.png
platforms/android-7/data/res/drawable-mdpi/spinner_black_48.png
platforms/android-7/data/res/drawable-mdpi/spinner_black_76.png
platforms/android-7/data/res/drawable-hdpi/spinner_black_16.png
platforms/android-7/data/res/drawable-hdpi/spinner_black_20.png
platforms/android-7/data/res/drawable-hdpi/spinner_black_48.png
platforms/android-7/data/res/drawable-hdpi/spinner_black_76.png
Though it doesn't currently, Android's official "Icon Design Guidelines" used to explicitly address this situation and recommend copying:
Because resources can change between platform versions, you should not reference built-in icons using the Android platform resource IDs (i.e. status bar icons under android.R.drawable). If you want to use any icons or other internal drawable resources, you should store a local copy of those icons or drawables in your application resources, then reference the local copy from your application code. In that way, you can maintain control over the appearance of your icons, even if the system's copy changes.