I'm looking for a way to dynamically convert a String like "30dp"
into an int that resembles the amount of pixels. This would mean that StaticClass.theMethodImSearchingFor("16px")
would return 16
.
My application will get these Strings dynamically and I need a way to store it as a pixel value to use later.
I've already looked at the Android Source code, mainly the classes Resources
, TypedArray
and TypedValue
, but I couldn't find anything useful.
If you need the android resource dimen as a int you can do this in your code:
context.getResources().getDimensionPixelSize(R.dimen.your_dimen_res);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With