When we center a div, there are generally two methods, one is to fix the left and right width, that is, to use absolute pixel positioning; the other is to use relative percentage positioning, in either of these ways, absolute positioning does not allow the div to adapt to the screen, but the percentage can be used. However, a new problem arises when the percentage is used, if there is such a sentence in our pageWhen this statement is deleted, the perc
When we have the div centered, there are generally two methods, one is fixed to the left and right width, that is, the use of pixel absolute positioning, and the other is a percentage of relative positioning, in this two ways, absolute positioning is not allowed to adapt to the screen, and the percentage can be, but, There's a new problem with percentages, if there's a sentence on our page
, the percentage of top will be invalidated, and the deletion
This question is not complex, but there are a lot of people asking, so I should concentrate on answering it.
Starting from Android 3.2 (API Level 13), use the following method in the activity to obtain the screen size (in pixels ):
Display display = getwindowmanager (). getdefaultdisplay ();//Activity # getwindowmanager ()Point size =NewPoint (); display. get
HTML>Script>functionA () {document.write ("The screen resolution is:"+Screen.width+"*"+Screen.height+""+"screen Available size:"+Screen.availwidth+"*"+Screen.availheight+""+"width of visible area of Web page:"+Document.body.clientWidth+""+"Web page Visible Area High:"+Document.body.clientHeight+""+"the width of the page's visible area (including the width of the
One, resolution Independent1. Using DP (DPI)Android uses density-independent pixels (DP) to specify the screen size, which allows zooming to achieve the same effect on devices with different pixel densities and the same screen size. (No problem with different screen sizes ye
control size in code
1 private Button mbtn;2 mbtn = (Button) findViewById(R.id.btn_test); 3 LayoutParams lp; 4 lp=mbtn.getLayoutParams();5 lp.width=100;6 lp.height=200; 7 mbtn.setLayoutParams(lp);
How to set the page size in the Code:
1 display = getwindowmanager (). getdefadisplay display (); // for obtaining
Browser | Adaptive to let flash adaptive browser screen size needs to do the following two points:
1, the SWF file with the browser screen size also changed greatly under;
Methods: In the Web page, in addition to putting your SWF file, do not put any other content, and SWF file width, height is set to 100%;(can look at
The traditional font size adaptation may fit according to the width of the screen with a ratio of iphone5 or iphone6 width. But if there is a need to display a font on the phone that displays the @2x picture, another fixed-size font appears on the phone that displays the @3x picture.So the point here is to distinguish between the
Dip or DP (density-independent pixels)Length (true length): inches, inchPixels per inch dpi (screen density)Pixels: pxDip formula: px/dip=dpi/160 (screen pixel/dip = screen density/160), inch = Px/dpi,dip=160*inchScreen 320*480, the number of pixels in the horizontal direction is 320, the number of pixels in the vertical direction is 480, the resolution is 160 (m
physical size: Refers to the size of the diagonal screen, usually in inches (inch) to indicate. Resolution: Refers to the number of pixel points that are contained within the unit length. For example, on a screen with a resolution of 1024x768, where each horizontal line contains 1024 pixels, there are 768 lines, that i
Java online chat project swt Visual Window Design login box Registration button click to change the window size -- the registration panel appears to enable the login box when the screen is centered,
Click the "register" button in the logon box to change the window size. The registration panel appears.
FirstUse swt to visually design the logon window, for example:
this article by Purplesword (jzj1993) original, reprint please specifyOriginal URL http://blog.csdn.net/jzj19931.px = Pixels, pixel value2.DP = Dip = device independent pixel, unit independent pixel (Android dedicated virtual pixel unit)3.density, screen density
(1) approximate conversion relationship px = dip*density, dip = px/density
(2) the same pixel value (px) of the control, on different density
In Android, the screen length and width are obtained.CodeBut the results do not match the actual results. For example, if my mobile phone is i9000 and the screen size is 480 * 800px, the result is 320*533.
The results were unreliable, so I wrote a few lines of code to test it.
Test parameters:
Test environment: i9000 (Samsung)
Physical
Hello everyone, This section describes how Android gets the screen size of a mobile phone. This section mainly uses three objects.
Textview ,
Button , And
Displaymetrics , Where
Displaymetrics Is the Key class for getting the phone screen size. This example is very simple. When we click the button to trigger the ev
look first for example the following layout:In The size of the button is half the screen, then centered in the center of the layout, each person has its own answer, see my method, layout layout XML such as the following:XML version= "1.0" encoding= "Utf-8"? >Here are a few key points:
The layout is linearlayout so that layout_weight can be set.
Set the value of the LinearLayout android:weightsu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.