I am working with map and trying to create marker as Drawable object from my layout file.
I need my marker view to change depends on the the type of point, and hence i declared my first image as static and my second image as dynamic(Change dynamically),but it is not working.
My layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/marker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/marker" >
</ImageView>
<ImageView
android:id="@+id/category"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/category_for_children" />
</RelativeLayout>
My code:
Resources res = getResources();
try {
marker = Drawable.createFromXml(res, res.getXml(R.layout.marker_on_map));
} catch (NotFoundException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Drawable.createFromXmlis not for loadingLayoutsorViewinto drawable!!see this sample of its usage:
http://spearhend.blogspot.com/2012/04/load-android-drawable-from-xml.html