Ok guys I\'m little stacked here. According to official documentation Google says that \"Once you\'ve defined your Drawable in XML, save the file in the res/drawable/ direct
Just create a drawable
folder by yourself and put your files there.
I have that problem sometimes.
I always create the XML drawable as "New text file". If you get an error after the XML drawable has been created, check the XML syntax to be sure there is no error in the file, and try to clean the project (Project->Clean->Your project)
Good luck
As of today, there is no "direct" support to drawable resources in Eclipse ADT.
So, from Eclipse Package Explorer, you should "manually" add a new folder named 'drawable' into your project 'res' folder.
Then, still from Package Explorer, you should manually add a new XML file within the newly created folder (right click\ new\ other\ XML\ XML File).
Why cant you use BitmapDrawable heres a sample code:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/drawable_resource"
android:gravity="center"
android:tileMode="repeat"/>
android:background="@drawable/drawable_resource"
and it will be tiled.Example:
<LinearLayout
android:background="@drawable/drawable_resource"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LineatLayout
Heres a complete template of Bitmap Drawable, you can choose attribute values accourding to your need.
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@[package:]drawable/drawable_resource"
android:antialias=["true" | "false"]
android:dither=["true" | "false"]
android:filter=["true" | "false"]
android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
"fill_vertical" | "center_horizontal" | "fill_horizontal" |
"center" | "fill" | "clip_vertical" | "clip_horizontal"]
android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />
You can find documentation of the same here look for XML Bitmap.
Drag and drop an image-button from "Images&Media" folder in palette. When the dialog for choosing an icon is shown, klick on "create a new icon" down below, enter a name for your new drawable (only small letters) and then choose your image and what the drawable is for (a button or what so ever). Remember to choose the right THEME, that you are creating the icon for (a light theme or a dark theme). Eclipse will resize the pic and do all the rest work for you to have good-looking drawable. After that, you can delete the image-button. It's a kind of strange, but it works that way the fastest and WITHOUT CODING and without any graphical working or any filemanagement!!!!
This worked for me in creating a "drawable" folder inside the res folder. Right click on the res folder->New->Other->General->Folder then Next
Select res from the set of folders under your project then
give it the "drawable" name and Finish!