The advent of live streaming and short videos has pushed the Internet into an era of Internet celebrity economy, and the update of smartphones has provided a “hotbed” for the development of both. However, with the increase of Android models, the degree of fragmentation of devices is also deepening. Therefore, in order to ensure the consistent experience of users under different Android models, we need to adapt various mobile phone screens.

Let’s talk about the adaptation of live broadcast system and short video system Android models.

1. Layout component adaptation

There are several different adaptation scenarios for component adaptation.

One is to use density-independent pixel DP or independent proportional pixel SP unit to specify the size;

The second is to use a RelativeLayout or LinearLayout. A RelativeLayout layout is a RelativeLayout that doesn’t change the screen size, whereas a LinearLayout can accurately control the position relationship between views.

Third, the size of components in the layout should not be fixed. Use warP_Content or match_parent and weights according to the situation, and cooperate with minWidth, minHeight and other attributes.

Fourth is the rational use of Dimens, the same component is defined in different sizes on different screens.

2. Picture adaptation

About picture adaptation, there are mainly the following aspects.

First, it is used in some specific scenes, assuming that the image name is 9. PNG automatic stretch bitmap, in the live broadcast system of private message chat box, 9. PNG bitmap can automatically adapt according to the content without deformation;

Customizing views and drawing with Drawable;

Third, Imagview ScaleType attribute adaptation;

Fourth, ordinary pictures and ICONS are cut according to The official density type of Goolgle and placed in corresponding positions according to the image size, as shown below:



3. Fit in the code

In the code, the Api provided by Google is used to measure the width and height of the screen. In some specific cases, the value is proportional, so that there is no need to consider the trouble caused by the inconsistent screen size.

The above is the direction of thinking about the adaptation of live broadcast system and short video system in Android mobile phones. Special attention should be paid to the development of live broadcast system or short video system. Only when the adaptation problem is solved can excellent live broadcast and short video APP be created to further improve user experience.