I am using this icon in my code:
android.R.drawable.ic_menu_close_clear_cancel
But it looks outlined, not simple cross:
I want to make it like this: https://storage.googleapis.com/spec-host-backup/mio-design%2Fassets%2F1Xlq7_lXkjBJDE6arihpaS3YWm4TSf2-S%2Fdialogs-fullscreen-behavior.mp4
Should I use another resource or tinting?
You can do it either way but Android advices against using platform resource ids. You can copy the icon into your drawables and use that resource id instead (and in your case tint it).
Android docs about the matter: https://developer.android.com/guide/practices/ui_guidelines/icon_design_menu
Warning: 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. Note that the grid below is not intended to be complete.
Related
I am integrating ActionBarSherlock in my app and I want to have some menus with some items and its respective icons.
I have looked into samples and documentation, and everything seems to be clear, but when I Inflate the menu, I can see just the text because there are no icons related to each item yet.
I would like to use the icons you see when creating an android project:
But I can't find it, and I don't want to use direct reference to android.R.drawable in order to use those clipart icons, because I have read it is recommended to have the files in drawable folders.
android-sdk/platforms/android-xx/data/res/drawable-yyyy
where xx is your target platform and yyyy is mdpi, hdpi, etc.
Copy the icons you want into the appropriate resource folder in your project.
I generally use Android Asset Studio to create icons for my apps. It has all the standard clipart, and can generate the proper files for all other icons as well.
http://developer.android.com/design/downloads/index.html site has Action Bar Icon Pack
You can use system icons by using "#android:" prefix. The icon is not copied to drawable folders, so the application size is smaller"
Example: android:icon="#android:drawable/ic_menu_preferences"
List of icons at /platforms/android-/data/res/drawable-hdpi
Note 1: If you want to copy the icons to drawable files you can also do it in eclipse by using file /new/other/Anddoid icon set/clipart button/choose button.
Note 2: the icon set could change among platforms. That is why people are suggesting to copy resources. If the applicacion is just at development state you could just link the platform icons
I'm trying to use the android.R.drawable stat_sys_download as the background image for a text view but it's not showing up:
textview.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.stat_sys_download));
If I use a different android.R.drawable like ic_menu_save it works fine:
textview.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.ic_menu_save));
I can however use stat_sys_download as an icon on a menu option so I know it exists:
menu.add(0, OPTION_MENU_SORTBY, 0, Str.TEXT_SORTBY).setIcon(android.R.drawable.stat_sys_download);
So why is it that I can use stat_sys_download as an icon but not as a background? Should I copy it into my resources folder and use it that way?
From Google's UI Guidelines for Status Bar Icons (also can be applied towards other drawable elements)
Warning: Because these resources can change between platform versions,
you should not reference these 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.
That's strange, though there's probably a difference between ic_menu_save and stat_sys_download in their formats which causes this problem. Can you try using setBackgroundResource(int resId) instead? Otherwise, try copying the resource to your local directory and see if that works.
Are there open source versions of the standard Options, Home, Back, and Search icons that appear on every phone?
Check out this page, it offers a convenient way to browse the built-in drawables, most of which you can use just by referencing them in your layout.
See for example, the item ic_menu_home. You can probably use it in a layout like so
<android:Whatever
android:icon="#drawable/android:ic_menu_home"/>
Although, as the author of the page mentions, you sometimes have to copy items from the SDK resources folder if the above method throws an error.
Note also that while this method isn't guaranteed to match the icon you see, it will match what the user will see for that logical name. For example, I used this technique to add the "Preferences" icon to an options menu, and the emulator had a different icon than what was shown there. When you want a "standard" icon, this is good, although if you really wanted an exact image you could copy it into your app's res folder.
Can you please tell me how can I use android's icon expander_ic_maximized?
I find that in frameworks/base/core/res/res/drawable-hdpi/expanderic_minimized.9.png
Here is my layout xml file:
<ImageView android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/expander_ic_minimized">
But I get this error:
res/layout/test.xml:70: error: Error: Resource is not public. (at 'src' with value '#android:drawable/expander_ic_maximized').
You can find all android icons in your android SDK installation directory. F.ex. /opt/android-sdk-linux/platforms/android-16/data/res/drawable-hdpi/ on my computer. There are different sets of icons for different android versions and for different screen resolutions. Copy expander_ic_minimized.png files to your project drawable folders and the icon will become available.
According to android developer guide:
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.
According to this thread, you will have to manually copy that icon into your project and use it from there.
Maybe just download and include it in your project
get it from expander_ic_maximized.9.png by clicking the View raw file link
I want to develop an android application, but i dont want to use the default controls(buttons, checkboxes, radio buttons, etc.,). Is there any way to customize those controls to make it appear nicer. If so some tutorial or guide will help me a lot. Thanks....
If you want to create completely new UI elements, you should read the developer guide topic on creating custom components/views.
If, on the other hand, you simply want to change the appearance of existing UI elements, below is a non-exhaustive list of things you'll need to do. This assumes you're familiar with the Android resources framework and layout system.
First, see how these are implemented in the Android source code (AOSP, GitHub's mirror). All of the code you're interested in is in the frameworks/base.git project (quick links: resources, Java sources)
For each type of UI element, create Nine Patch PNG drawables for each of the UI states (default, disabled, pressed, focused, etc.) and for each relevant density (e.g. medium, high , and extra-high densities). These PNGs should be in your res/drawable-mdpi/, res/drawable-hdpi/, and res/drawable-xhdpi/ directories.
For each type of UI element, create a state list XML drawable (<selector>), which will be in your res/drawable/ directory. The state list drawable for the default Android push button can be found here.
Set your button/textbox/etc.'s android:background attribute to the state list drawable name. For example, the attribute value should be #drawable/mybutton if your state list drawable is res/drawable/mybutton.xml. Note: You can use themes to reduce redundancy (i.e. keep them DRY) in your XML files.