Introduction
According to google's official display, Android 4.0 and above already have 34.2% million devices. As many mobile phones in China have no chance to use the google play market, you only need to read the quarterly reports similar to those of umeng. I personally think that Android 4.0 and later devices will have a desire for use. The previous versions are limited by hardware and system optimization. I personally think that, in addition to making a phone call, receiving a text message, reading a microblog, and using QQ, there is not much value that can be used by people. As for the reasons, you will know everything you know, I don't know either. Now, with the development of hardware technology, we can easily purchase mobile phones and tablets after Android 4.0 with strong performance and low price. Now we are learning about android 4. the design style of X is not too late.
Responsive Design
The title of this article is class responsive design. Anyone who has done web development should know the so-called responsive design, is a web page can be based on computer access or mobile access to a response to the display, in the google official design guide document, there are also related instructions: http://developer.android.com/design/patterns/multi-pane-layouts.html, compared with the responsive design of the web, Android can only be called as a similar design. In contrast, the web terminal is complicated and Android is relatively simple, in Android, you only need to consider when to display a pane and when to display two pane.
Theoretical Basis of Design
To solve the problem of Android apps displaying a pane and two pane, we need to know how Android solves compatibility issues in various resolutions.
In the era of desktop software, we seldom find that some people talk about different resolutions. As for the reason, I personally think that, first, there are a lot of computer resolutions, however, the dpi/ppi on the screen is similar, which makes the display of measurement parameters in pixels on different screens not very different. Second, that is, the windows of the software on the pc are adjustable, And you rarely see the windows on the mobile phone or tablet (of course, some Android devices of Samsung now support this ). However, mobile devices are completely different. First, the compatibility problem arises, rooted in the problem of how big a pixel is to be displayed. On a high-density mobile phone screen, A pixel is displayed very small, so we assume that we want to display a length of about 100 with 2 cm pixels, but only 1 cm is displayed. The second point is, mobile devices do not support Window Scaling. If I define a unit of 100 pixels, there will never be any space for users to adjust. In fact, Android has provided a good solution to this problem, that is, it does not rely on the measurement units of pixels and allows the system to render pixels according to the screen density.
One image:
One formula:
Px = dp * (dpi/160)
If you strictly follow the above two points to design your program, then you do not need to worry about resolution compatibility issues. Of course, to do this, you need to worry about the design.
Android Program Implementation
I have discussed a bunch of theoretical things above, and it is estimated that everyone is tired of reading them. How can I implement it on Android?
Design Rules
First, let's look at a figure:
From this figure, we can roughly understand the simplest difference between a mobile phone and a tablet, that is, whether one side of the screen is greater than 600dp. Then we will draw a flowchart:
Show one pane or multiple pane
If we put the design of the tablet and mobile phone, we simply think that a pane is displayed on the mobile phone and multiple pane is displayed on the tablet, which is too superficial.
In terms of web design, we have a div concept. For this concept, we can smoothly transition to the design of our Android Application. After android 4 and later, it was actually Android 3. google realized that the charm of the Android tablet was not enough for us to develop the tablet for another time (such as iPad ), therefore, a web-like design scheme is introduced to completely separate each view, so that the activity is only used as the container of these views. Before the fragment is launched, we need to make a design, it takes a lot of effort, because we need to manually maintain the life cycle of each view, and with fragment, we have a stable mechanism (compatible with packages earlier than Android 4 ). Next, we only need to consider how to deal with the entire logic of our application. After studying multiple Android adaptive apps, we come up with a rule about 600dp.
The so-called 600dp Law
We can know from the above that the difference between a mobile phone and a tablet is long or as high as 600dp, so what can this 600dp do? First, 600dp is the distinction between a mobile phone and a tablet. The biggest difference between a mobile phone and a tablet is how much content can be displayed on a screen. If the cell phone is displayed as a pane unit, we can consider putting one more pane under one screen if it is greater than 600dp. (For more information about why 600dp is selected, see google android apps)
Now, we take the open-source Chinese client as an example to illustrate how to use this rule in practice.
The original client displays the following information on a mobile phone:
The following figure is displayed on a flat panel (with a width greater than 600dp:
We can easily find that for devices larger than 600dp, screen utilization is far from enough. Next we will use the 600dp rule for this purpose and display it after the revision.
After transformation according to the 600dp rule, the following information is displayed:
About landscape screens
We all know that there seems to be a lot of free space after the mobile phone landscape screen, so can we consider putting multiple pane?
First, we need to consider whether our applications target tablets or mobile phones, rather than how to make good use of the screen space, here, 600dp is the best size for cell phones and tablets. If you want to consider the design of mobile phones and tablets, you only need to consider the differences between an app on mobile phones and tablets. If you want to make good use of screen usage, please design one set based on your phone or tablet.
Recommended books
Http://developer.android.com/guide/practices/screens_support.html
Http://developer.android.com/training/multiscreen/screensizes.html