At present popular UI adaptation see big guys are using toutiao adaptation scheme with SW qualifier adaptation scheme.

Why isn’t anyone using AndroidAutoLayout now?

Github.com/hongyangAnd…

AndroidAutoLayout has a design problem. What is it? See the link below

www.jianshu.com/p/f770ef841…

AndroidAutoLayout fills the screen perfectly with the height and width of the page on any screen, but as long as the device’s aspect ratio is not consistent with the aspect ratio of the design drawing (the aspect ratio of the design drawing is generally 16:9), the View will be severely distorted. On device 9, the square View has become a rectangle.

Since AutoLayout only supports 16:9 phones, the aspect ratio of the phone screen is not 9:16, AndroidAutoLayout screen adaptation will have problems, resulting in a serious distortion of the View. Can I help him recalculate the width and height?

MScreenWidth = (int) (scale2 * mScreenHeight); scale2 * mScreenHeight = (scale2 * mScreenHeight); This adaptation is based on height, not a percentage fit for width, but similar

MScreenHeight = (int) (mScreenWidth/scale2); mScreenHeight = (int) (mScreenWidth/scale2) This width-based adaptation is not as good as a percentage fit at height, but it is similar

Simply add the following code when the AutoLayoutConifg init method initializes the width and height to solve the 16:9 adaptation problem

So changed the pro test development of N projects adapted to no problem!

public void reSetScreen() { double scale = (double) mScreenWidth / mScreenHeight; double scale2 = (double) mDesignWidth / mDesignHeight; BigDecimal bg2 = new BigDecimal(scale2); scale2 = bg2.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); double ss = scale - scale2; Math. Abs (ss) >= 0.0001) {if (ss > 0) {mScreenWidth = (int) (scale2 * mScreenHeight); } else { mScreenHeight = (int) (mScreenWidth / scale2); }}}Copy the code

Toutiao screen adaptation scheme and SmallestWidth screen adaptation scheme are also not 100% suitable, they are also based on a wide or high school as a benchmark for screen adaptation.