In most cases, are layout in xml, using units of dip, it has nothing to do with the density, the results are still ok. However, some things in the code set of direct aspect, size, etc., the value of which is a set of type int, and no units (do not know can set the unit), the outcome of the effect on the retina screen on the difference great, seeking guidance about genius.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
More anxious, seeking guidance
Reply:
The default code is pix, turn into a dip on the line
Reply:
public static int dip2px (Context context, float dpValue) {
.. final float scale = context.getResources () getDisplayMetrics () density;
return (int) (dpValue * scale + 0.5f);
}
Reply:
Size-related resources can be placed res/value- *** / demins.xml, the different resolutions on different value loaded demins.xml directory
Reply:
This can only fit a few others were rate, if you really want all the screen adaptation, it needs its own calculation,
Several criteria can be used as the resolution and dynamic calculation of all the components of the size
For example, to 720p as the standard renderings with Xwidth said that the current screen width currentWidth
Width of the component is trueWidth = currentWidth * (Xwidth/1280)
The calculation is the same height
No comments:
Post a Comment