Everybody help!Bloggers participate in 2014 blog star activities, we help vote! Punch here!It is a very interesting thing to know the hardware through the program. I studied the physical size of the screen on WM6.5, but it has not been successful. Later, I wanted to make a breakthrough on Android, but I didn't get the exact size before today. Although many people
Size Units (px, dpi, dp, dip, and sp) of the View for android Application Development, and androiddpi
I. pixel (px) and screen resolution
1) px (Pixels, Pixels): corresponds to the actual Pixels on the screen. For example, 320*480 screens have 320 pixels horizontally and 480 pixels vertically.
2) the screen resolution is the total number of physical pixels displayed on the screen. It is equal to the number
This article illustrates how Android gets the size of a mobile screen. Share to everyone for your reference, specific as follows:
There are mainly three objects TextView, buttons, and Displaymetrics, where Displaymetrics is the key class to get the size of the phone screen , this example is very simple when we click on the button to trigger the event, Display th
Http://blog.csdn.net/ljianhui/article/details/43601495?ref=myreadOne, pixel (px) and screen resolution1)px (Pixels, pixels): corresponds to the actual pixel point on the screen.For example, the 320*480 screen has 320 pixels in the landscape and 480 pixels in the portrait. 2) The screen resolution is the sum of the physical pixels displayed on the screen, which equals the pixels on the width of the screen on pixels * height. On the development of Android
UI elements of different sizes.
3. SP
Scale-independent PIXELS:SP Unit is consistent with DP, the difference is that SP units support scale, and when the user adjusts the standard font size in the settings, the PX corresponding to each SP will change.
How is the screen size defined in Android?Screen Size
Android get folder, file size in B, KB, MB, GBpublic class Filesizeutil {public static final int sizetype_b = 1;//Gets the double value of file size unit B public static final int sizety pe_kb = 2;//Gets the file size in kilobytes of double value public static final int sizetype_mb = 3;//Gets the file
First, let's take a look at several concepts.
Screen size
The actual physical size is calculated based on the diagonal line of the screen. For example, iPhone 4 is a 3.5 inch screen, that is, its screen diagonal line is long. 1 inch is about 25.4mm. The size unit points mentioned later is equal to 1 inch of 1/72.
For simplicity,
{.((TextView) v). Settextsize (Adjustfontsize);15.}16.}17.}18.}19.20.21.//Get font size22.public static int adjustfontsize (int screenwidth, int screenheight) {screenwidth=screenwidth>screenheight?screenwidth:screenheight;.24./**25. * 1. Get the view width in the onsizechanged of the view, usually the default width is 320, so calculate a zoom ratioRate = (float) w/320 W is the actual width27.2. Then when setting the font size paint.settextsize ((int)
First, preliminary thinking
Although the Android display adaptation of the scheme is a bit strange, initially it is not easy to understand immediately, but this program does have its own truth, the whole idea is clear, the plan is complete, no mishap
The "screen density scaling mechanism" used by Android, which corresponds to the Web front end, is the "screen scale reduction mechanism"
Share: My Android News client, fast, small size, support offline reading, easy to operate, content presentation form rich and varied, information is large, full function and so on (to the code of the left mailbox)Lasted 30 days in order to develop this news client app, the following abbreviation for the smell http://m.yunxunmi.com/Because I am relatively dull, not very good at the use of various open source
How does the font size of Android adapt to different resolutions?
Someone asked me today how to adapt the font size of mobile phones with different resolutions and sizes in the android system? In fact, the adaptation of fonts and images is a truth.
I,
The principle is as follows:
Assume that the resolution is 320x240,4
Android has been widely sought after since its launch. Due to its open features, the market has emerged immediately. Different Versions of Android machines, different Android OS, and different OEMs, of course there will be a lot of inexplicable screen sizes. for this reason, I introduced in my previous article how to get the width and height of the
the size of the APK file:How to optimize the source file:
Master good coding habits, reuse code, for some repetitive code logic reuse;
Using Proguard to confuse code, optimize, compress (it's not just a cow rub obfuscation tool is also great in code optimization).
By reducing references to useless code libraries, a common scenario is that some code libraries are not needed, but they are still referenced in the code, and the c
1. Set the text style (such as color and italic) in textview. You can set different styles for text in different positions.(For example, set the characters with an index range of 1-3 to black, and 2-6 to bold)
Myfirsttextview = (textview) findviewbyid (R. Id. myfirsttextview );
Myfirsttextview. settext ("this is my first textview, ", buffertype. editable );
/**
* Set the background color of the text,
* The text must be set to buffertype. spannable and buffertype. ed
, Getwindowvisibledisplayframe () execution results will be affected by the system status bar, System soft keyboard, system virtual keys.It is important to note that the result of Getwindowvisibledisplayframe () is not the actual size of the window (although it has a certain relationship to the size of the window). For example, a Center Display dialog box, its actual height is only 500px, it and the system
The screen size of Android mobile phones has always been a headache for developers. Because the screen sizes used by mobile phone manufacturers are different, the presentation and layout of user UI interfaces are naturally different. Therefore, when developing Android mobile appsProgramIn addition to understanding the underlying API, the most important thing is t
The concepts of PX, dip, SP, and DP are vague. I checked it online and found it clearly in theory.
1. PX (pixels): the point on the screen, which is related to the density. The density is high, and the PX size per unit area is large.
2. Dip or DP (pixels unrelated to density ). This is related to the hardware of the device. We recommend that you use this feature to support WVGA, hvga, and qvga 5 hexadecimal space. An abstract unit based on screen
/** Obtain the window manager and default display, which we'll use to * find out the size of the Devi Ce ' s display (in pixels)*/WindowManager WindowManager=(WindowManager) Getsystemservice (Context.window_service); Display Display=Windowmanager.getdefaultdisplay (); /*Obtain the API level of the device running the game*/ intAPI =Android.os.Build.VERSION.SDK_INT; /** we ' re dealing with deprecated methods, so We filter older devices * (less t
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.