2

Is something like this possible with Roboguice on Android?

<resources>
   <dimen name="radius">10dip</dimen>
</resources>

and then

@InjectResource(R.dimen.radius)
private int radius; // in px

Thanks!

Thomas Keller
  • 5,933
  • 6
  • 48
  • 80

1 Answers1

2

I looked into sources and there are supported types as:

  • String resources.getString(id)
  • boolean resources.getBoolean(id)
  • ColorStateList resources.getColorStateList(id)
  • int resources.getInteger(id)
  • Drawable resources.getDrawable(id)
  • String[] resources.getStringArray(id)
  • int[] resources.getIntArray(id)
  • Animation AnimationUtils.loadAnimation(application, id)
  • Movie resources.getMovie(id)

I couldn't find int resources.getDimensionPixelSize(id). That what you could do is to keep dimension as an int value:

<resources>
   <integer name="radius">10</integer>
</resources>

But it's not a clean solution.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
pawelzieba
  • 16,082
  • 3
  • 46
  • 72