androidandroid-activity

Loading drawables different contexts


Is there a difference in loading drawables programatically using applicationContext vs Activity Context


Solution

  • Yes, in some cases there is a difference.

    Application and Activity can have different themes (specified in the AndroidManifest.xml).

    Certain types of drawable resources (e.g. shape drawables) can reference attributes that depend on the theme (e.g. colors).

    This can cause the same drawable to look differently when created using application and activity contexts.