Essay One:
PX: The simplest understanding of physical pixels. Before the rpx of the front end is 1:2 of the relationship, subconsciously think that PX and DP is a 2:1 relationship, it is not, and because of the number of Android devices, so it is based on the resolution to remember.
DP: To be detailed in detail; first, simply record the presence of the DP to ensure that the components appear in roughly the same visual size on phones with different resolutions. The clearer the screen resolution, the higher the 1DP contains the more pixels that are equal to more px.
SP: the size of the font varies with the size of the screen, depending on the size of the system, which is small and large.
Essay Two:
In general, depending on the model of the different screen size is also sometimes to be based on the screen size of the corresponding high-width settings. This can be done in Java:
Viewgroup.layoutparams recycleviewparams = mrecommandgrid.getlayoutparams (); if (recycleviewparams!=null) { int mpadding = densityutil.dip2px (GetContext (), ten); int mscreenheight = getcontext (). Getresources (). Getdisplaymetrics (). heightpixels; int mscreenwidth = getresources (). Getdisplaymetrics (). Widthpixels; Recycleviewparams.height = MSCREENHEIGHT/4; = mscreenwidth-2*mpadding; Mrecommandgrid.setlayoutparams (recycleviewparams);}
Project Essay Size series: Px,sp,dp;java set Size (layoutparams)