Foreword: designed a lot of units about this problem, what PX, PT, DP, SP, mobile phone size, PPI and so on, I only introduce me here to lift more reliable. If you have a better screen fit, please leave a link in the comments section. Thank you very much

1. Minimum width qualifier (recommended)

What is the minimum width qualifier?

Yes, a folder that ends with values- SW360DP is at the same level as the Values file in your project.

Let me put it in my own words: Google recommends using dp(just like Apple recommends using PT), which means screen density. You can tell by the density. While the various Android sizes have a lot of resolution, it’s pretty small when measured in terms of density. In simple terms: on a 1-inch screen, the pixels are the same

1.1. Thanks to ScreenMatch

Detailed link, thanks.

Once you know how to use ScreenMatch, let me talk a little bit about ScreenMatch. Properties, which is automatically generated by the plugin:

The dot looks something like this

############################################################################ # # You need to refresh or reopen the project every time you modify the configuration, # or you can't get the latest configuration parameters. # ############################################################################# # # Base dp value for screen match. Cut the screen into [base_dp] parts. # Data type is double. System default value is 360. # I advise you not to modify the value, be careful !!!!!!!!! _^_ *_* # The reference value for the minimum width on the plan. Also need to match the phone screen of [match_dp]. # If you have another dp values. # System  default values is 320360384392727 2, 5, 400410411428, 432480533592600640662720768800811820960961102, 4128, 0136 # 5 What are the minimum width to fit the width match_dp = 320360384392727 2, 5, 400410411428, 432480533592600640 # If you not wanna to match dp values above. Write some above values here, append value with "," . # For example: 811961136 # 5 need to ignore what the width of the adapter ignore_dp = 662720768800811820960961102, 4128, 0136 # 5 They 'r e not android module name. If has more, split with , Symbol. # If you set, it will not show in SelectDialog. # If you have, write here and append value with "," . # For example: testLibrary,commonModuleCopy the code
  • Base_dp =360 And this is the dp value for the entire screen of your design. As long as the Settings, mobile phone adaptation, the size of the control can go according to the design. Super convenient
  • Match_dp = 320360384392727 2, 400410411428, 432480533592600640, what are the minimum width to fit width
  • Ignore_dp = 5, 662720768800811820960961102, 4128, 0136 need to ignore what is the width of the adapter


1.2. Adapt mobile phone & tablet at the same time

The first thing we need to know is that there should be two sets of layouts for both phones and tablets. Make a phone set make a tablet set. That’s a good thing to know. We all know that cell phone screens typically range from 3 inches to 5 inches, and tablet screens range from 7 inches to 10 inches. So the phone will run the layout directly from layout. Let’s define a layout-SW600DP folder on the same layer as Layout. The layout inside is flat. Of course you want to be more elaborate and can negotiate different sizes of folders. The following



I ran it first on my phone, then on my tablet. Same project, look at the effect


1.3, simultaneously adapt horizontal and vertical screen

When you use the screenMatch plugin, don’t generate a lot of folders with the minimum width qualifier swXXdp. The minimum width qualifier does not distinguish between horizontal and vertical screens, so the minimum width is the minimum width. It would be confusing to switch between vertical and horizontal screens. Meaning you set a control that takes up half the width of the screen in portrait, but not half the width when you switch to landscape. How do you do that? Remove the S of swXXdp in front of the plugin generated folder and change it to wXXdp. In general, the current direction is the direction of the minimum width. Here’s what it looks like (this is configured so I didn’t do anything but rotate the phone to see how it works) :

I’ll just mention it a little bit and I won’t go into details. Use the vertical qualifier if you want a separate adaptation for landscape or portrait

  • Values -SW400DP-land (minimum width 400 DP)
  • Values -SW400DP-port (minimum width 400 DP vertical)

About the demo link above

2. Screen resolution qualifier (use with care)

What is a screen resolution qualifier?

First of all, thanks to Zhang Hongyang’s automatic generation tool

However, after my detailed test, I found that the problem was very big. First, this is itself a drawback of the screen resolution qualifier. Let’s take a look at my test. I used a real test machine,

Apparently my phone has a 1080 x 1920 resolution. Here we can analyze from lay_x. XML. The first thing I did was create these folders at the design width of 375. Then I put two controls in the Activity, one set to @dimen/x375 and the other set to @dimen/x187. But it doesn’t turn out to be a full screen, a half screen. Then I was surprised so I printed the current @dimen/x375 length and the current screen width in the Activity. The result is this:

It turns out the screen width is 1080. But @dimen/x375 is 800. Then I looked in the values folder and found the values-1280×800 folder was 800px. But I’m a little weird. Now that I have the values-1920×1080 folder. Why don’t you go? !!!!! I will delete the values-1280×800 folder later. Values -1280×768. I was in shock. I was in shock. I was thinking, I screwed up some of my projects. !!!!! Delete the values-1280×768 folder. The result is a delete again, the system has been looking up. I’m not looking for 1920×1080. There is no way to continue to find information about this mechanism. Just give me the link

Misused screen resolution qualifier Android screen adaptation, compare the full scheme

Use the screen resolution qualifier with caution. It doesn’t stand the test like screenMathch. If you have a better screen fit, please leave a link in the comments section. Progress together. 3q

Three, Toutiao screen adaptation scheme

Toutiao screen adaptation solution Ultimate version, a very low cost Android screen adaptation solution ByteDance official article summary: After practical tests and a large number of virtual machine tests, Toutiao uses 360DP as an example, and 160Dpi as an example. Just try it without changing the code. After setting 360DP, 160DPI phone is fine, but not 160DPI is not full screen. And if the dynamic gain dpi: appDisplayMetrics densityDpi. Only to find that it still cannot achieve the effect as stated in the official website article. Am I missing something? And all IT platforms are based on official website articles as examples, 360 and 160. Have you really tested it with multiple models? Hope to have a better understanding, can solve my doubts!!