Any way to compute density independent pixel size for UIs on android? thanks.
I haven’t done something like this, but i think, you can get screen dpi with android api in java, pass it into your C++ code via JNI, and then scale all your widgets using this variable
Hi, you could pass as an argument to your urho app.
SDLActivity.java
protected String[] getArguments() {
// Urho3D: always return the "app_process" as the first argument instead of empty array
String[] ret = new String[3];
ret[0] = "app_process";
String lang = Locale.getDefault().getLanguage();
ret[1] = lang;
DisplayMetrics metrics = getResources().getDisplayMetrics();
String dpi = Float.toString( metrics.xdpi ) + "," + Float.toString( metrics.ydpi );
ret[2] = dpi;
return ret;
}
MyApp.cpp (urho3d application subclass)
#ifdef __ANDROID__
Urho3D::Vector<Urho3D::String> args = Urho3D::GetArguments();
if( args.Size() >= 1)
m_appLang = args[0];
if( args.Size() >= 2)
m_screenDPI = args[1];
#endif
hope this would help.
Best regards.
Good solution, I think your code can be picked into master branch.