2

I need to choose a specific dimens.xml at runtime after my app checks for screen capabilities. I DON'T WANT ANDROID CHOOSE IT FOR ME by selecting automatically by project folder (\values, \values-large, ...).

I have to do it manually due to the bad screen configuration (density and dimension) of my low-cost china tablet. Can I do that?

Goo
  • 1,318
  • 1
  • 13
  • 31
Seraphim's
  • 12,559
  • 20
  • 88
  • 129

2 Answers2

2

Solved using styles/themes/... and activating a specific theme at runtime in onCreate() as described here:

android dynamically change style at runtime

Community
  • 1
  • 1
Seraphim's
  • 12,559
  • 20
  • 88
  • 129
1

Have you tried to force configuration change?

    DisplayMetrics metrics = new DisplayMetrics();
    metrics.densityDpi = DisplayMetrics.DENSITY_MEDIUM;
    metrics.setTo(metrics);

Not sure if it works though. It's generally a bad idea to ignore what the OS thinks is the best.

RobGThai
  • 5,937
  • 8
  • 41
  • 59