Where to find Android's original resource images - android

Does anybody know, where I can find the original image-files (button backgrounds, menu icons, etc.) used by Android? I'd need something like the text input background for my own view, but would like it to match the existing style as exactly as possible. Also I need the correct padding etc. But besides checking out the whole Android source from Github I have no idea where to find those images.

Go to the folder where you installed the Android SDK. You find the resources in
platforms > android-* > data > res > drawable-*

the ids of the default android resources are saved in the android R class:
getResources().getDrawable(android.R.drawable.*);
Note that R is android.R here and not your.packe.name.R!
The original files are saved in the sdk:
under platforms/android-8/data/res/drawable e.g. you can find them

I found it:
/home/quyen/Android/Sdk/platforms/android-15/data/res/drawable-mdpi

Related

android customize drawable folder to subfolder

Sub-Folder I didn't mean the drawable-hdpi, drawable-mdpi, drawable-ldpi, etc
but #drawable\myfolder\img.png
I'm a bit concerned on customizing the folder structure in drawable similar the way we have package to structure the java files.I'm using too many images for my project and when I try to copy activity layout xml; searching for the images in drawable, I felt it boring! Does android have such feature or some wayout?
I think, currently this way exists. I also have many drawables and layouts, so tried to start from layouts and then added drawables and menus. I recommend to see Can the Android Layout folder contain subfolders? and http://alexzh.com/tutorials/how-to-store-layouts-in-different-folders-in-android-project/.
Yes, I have now new resources in new subfolders. It requires time to manage (create res folders, edit build.gradle), but a folder tree becomes more neat. Sometimes AS cannot find resources during compilation. In this case I have to create new folders and edit build.gradle. Probably after several weeks everything will be done.
UPDATE
It has worked until Android Studio updated to 3.2 (and 3.2.1). Currently if you move any drawable, layout, menu resource to another folder (and add this folder to build.gradle as written in the articles above) you cannot normally use it. Before 3.2 we could simply press Build > Rebuild Project and reference to that resource. Now they have broken this behaviour and you should press File > Invalidate caches / Restart... > Just Restart (or close and open AS) to access this drawable as usual. If you don't want to restart AS, you can use the resource, but write a path to it manually like #drawable/reset_password, AS won't hint as you type and won't draw it in Design tab.
If you use Kotlin Android extensions and reference to ids like send_button (without findViewById()) you will get so many bugs that can't imagine. If you change resources, often nothing changes in layouts until you rebuild the project. This is because Kotlin caches resources. I often forget about it and waste hours.
As far as i know, NO.
There was an interesting post on G+ with a workaround for the layout dir, that works also for the drawables dir. I guess.
All the infos are here
Android doesn't support subfolders within its predefined directories, the only thing possible is for you to create directories within the res directory

"Duplicate Resources" error when building Android app

When I build my Android app, I get this error:
Error:Error: Duplicate resources: E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png:drawable-hdpi-v4/login_bg, E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png:drawable-hdpi-v4/login_bg
Error:Execution failed for task ':app:mergeDebugResources'.
> E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png: Error: Duplicate resources: E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png:drawable-hdpi-v4/login_bg, E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png:drawable-hdpi-v4/login_bg
I am not able to properly understand the error. What file is duplicated here? What am I supposed to do to rectify it?
The reason you are seeing this error is because Android considers the following images to be the same, based on how they are referenced in your layouts:
E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.png
E:\Android\LED\app\src\main\res\drawable-hdpi\login_bg.9.png
The first image, login_bg.png, is a normal image. The second image, login_bg.9.png, is named in such a way to tell Android that it is a 9-patch image. However, in terms of referencing the images, they are declared the same, as in the following examples.
Normal image:
<ImageView
android:id="#+id/normalImage"
android:background="#drawable/login_bg"/>
Nine-patch image:
<ImageView
android:id="#+id/ninePatchImage"
android:background="#drawable/login_bg"/>
Note: There is no difference in terms of referencing the images from the /res/drawables directory of your Android project.
See here for more info about nine-patch image, or the correct term for it is nine-patch drawable. For reference, nine-patch drawables must be declared as <name>.9.png, as in login_bg.9.png.
Therefore, simply renaming them will not solve the issue. You need to check with whoever developed the UI to see which one should be used: either the normal image (login_bg.png) or the 9-patch image (login_bg.9.png)—not both.
This error message will occur whenever the build tools detect multiple files with same name, regardless of their extension type.
For example, a file named mypicture.jpg cannot be in the same folder as mypicture.png.
In your case, login_bg.9.png and login_bg.png cannot be in the same directory.
Therefore, what you need to do is change the name of (or delete) one of the files.
Delete the image from drawable directory, because you are using same name within one folder, which is not allowed.
After I changed the initial/default ic_launcher via Resource Manager>>Image Asset>>Icon Type>> Launcher Icons
I got this error.
It happens because the initial icon still exists and with the same name inside the mipmap folder.
the solution for me was to delete the initial launcher icon.
Solution: Change your view to Project, find the initial icon, and delete it, then the error should be gone.
Solved this by going to
Build ➞ Clean Project
Using Ant instead of Gradle seemed to fix the issue for me. Many of my files have the same filename to start with a different extension (indexed resource files of various types). Ancient project, and the ancient solution worked for me.
I find a same string name in my two diff .xml file,
//a.xml
<string name="dialog_subscribe">关注</string>
//b.xml
<string name="dialog_subscribe">subscribe</string>
then i solved it by rename one of then

Is there any way to use not public android resources in my application?

I need to use the following resources in my widget:
pressed_application_background_static
focused_application_background_static
I hope that usage of these resources will allow me to have orange background on standard android and green on HTC.
But they are not public, so usage of
android:drawable="#android:drawable/pressed_application_background_static"
is not allowed. Is still there any way to use them?
You can reference them like this
android:drawable="#*android:drawable/pressed_application_background_static"
but it is not recommended, because private resources are likely to be renamed or removed in the future.
browse the sdk for the drawable and copy it locally to you res/drawable folder. it will probably be an XML file but if you search for "pressed_application_background_static" you should find it without trouble.

Any possibility to get autocompletion / type-ahead / intellisense in Android XML Files (Eclipse)

Is there any way to make Eclipse + Android SDK + ADT Plugin offer some sort of auto-complete in XML files if I hit CTRL+Space when my cursor is in a spot such as the ones marked with an * below.
<LinearLayout id* ... lay*>
The thing is that I think that the above was actually working already directly after the initial install - even though it of course never worked within style files.
<style name="ActionBarWrapper" parent="Fill_Parent.Vertical">
<item name="android:layout_height">36dp</item>
<item name="a*"
</style>
There is an icon in the eclispe toolbar to directly access the "new android xml file" wizard.
You could use IntelliJ IDEA instead of Eclipse, it has full auto-completion and works well for Android development.
http://www.jetbrains.com/idea/
The Community Edition fully supports Android, and is FREE
The latest ADT plugin (r9) does have partial auto complete feature in the layout xml.
for example, if you type ctrl-spacebar while the cursor is between 2 tags, you get the list of all avaliable tags (views and layouts). If your cursor is inside a tag, you get a list of all avaliable attributes.
First of all: Thanks for the good advice everybody. Not sure if the following should be an answer or a comment. Going for the answer because comments do not allow enough characters.
After trying out some eclipse plugins (like Rinzo XML Editor ) I found out that it actually worked for some files while it did not work at all for others. After some testing I am now under the impression that there is a difference between creating XML files via...
New > XML
and
New > Other > Android > Android XML File
I double checked that even when both files have exactly the same content (xml-version, encoding, namespace etc.) they behave differently with regards to auto-code-completion depending on the way of file-creation. I also checked the file properties but could not make out any significant differences. Obviously it must be something local or some meta stuff I am overlooking.
I think the different behavior is because when you create the file using "New->XML" the wizard opens the file using the default associated editor to xml content.
If you create a file using "New->Other->Android->Android XML File" I think the wizards tries to open the xml file using a specific xml editor, instead of the one you have configured as default, in this case Rinzo I guess.
In the second case why don't you try finding the xml file in either "Package Explorer" view or "Navigator" view, right click on the xml file and selecting Rinzo through the "Open With" option.

How can I use a system provided icon in Android (e.g. expander_ic_maximized)

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

Categories

Resources