I made an application where I create part of the interface in xml and part via java code, the part in xml works in any application adapting the screen size correctly. The part via code on a 7.8-inch device looks good, however on a 4-inch screen it's all unconfigured (source of the giant views). I've done a lot of research on the internet and nothing works. Anyone know what I can do? Thank you in advance.
I tried to use this code but it did not work:
tv2.setTextSize(20 * getResources().getDisplayMetrics().scaledDensity);