Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

SpriteFactory.fromResource returns null for XML drawables #3107

Closed

Description

@tobrun

Code that currently returns a null sprite for xml drawable ic_flag:

Sprite sprite = new SpriteFactory(mapView).fromResource(R.drawable.ic_flag);

Step into that code:

public Sprite fromResource(int resourceId) {
   Bitmap bitmap = BitmapFactory.decodeResource(mMapView.getResources(), resourceId);
   return fromBitmap(bitmap);
}

It seems that decodeResource doesn't work for drawables defined in xml. It is trying to directly load the referenced file instead of loading the files referenced by the xml. See this SO-post.

Note: ic_flag is a vector drawable generated with Android Gradle Plugin 1.5.0

Activity

  1. added
    Android
    on Nov 24, 2015
  2. added this to the android-v2.3.0 milestone on Nov 24, 2015
  3. modified the milestones: android-v2.3.0, on Dec 4, 2015
  4. tobrun commented on Dec 18, 2015

    @tobrun
    MemberAuthor

    Taking this up, by default fromResource in SpriteFactory only allows Bitmap.
    Will expand support to handle VectorDrawable and others as well.

  5. added a commit that references this issue on Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Androidbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions