android127 zhihuibeijing Screen Fit

Source: Internet
Author: User

# # Screen fit # #加载不同分辨率的图片是根据手机的像素来加载不同分辨率文件夹下的图片. > First in the main screen to send: the*720(resolution and phone screen size independent), follow the principle: no absolutelayout (absolute layout), multi-use relative layout &linear layout (weight), with DP, without PX> > Late Development, test on different resolution screens (480* -,1920x1080* the), if there is no big problem (affecting normal use), you can go online> > What if the problem is detected later?picture adaptation is not very common, for different resolutions of the phone to do different pictures. -layout adaptation is not very commonly used, layout-800x480Specially adapted 480*800 layout file for the screen. -size fit DP and PX Relationship: DP= px/device density (pixel px is the real screen unit)floatDensity =getresources (). Getdisplaymetrics (). density; System. out. println ("Device density:"+density);  the* -(0.75),480* the(1),480* -(1.5), the*720(2) under the Values folder, create a dimens.xml file that values-1280x720 folder to create a Dimens.xml file, these 2 dimens.xml respectively write <dimen name="Textview_width">320dp</dimen>used to load different sizes on different screens. -weight adaptation weights only have linear layouts. Android:weightsum="3", the parent layout has a total of 3 weights, and a total of less than 3 sub-layouts is left blank. -code adaptation get screen height, dynamically calculate control sizeintwidth = Getwindowmanager (). Getdefaultdisplay (). GetWidth ();//width of the screen        intHeight = Getwindowmanager (). Getdefaultdisplay (). GetHeight ();//the height of the screenTextView TV1=(TextView) Findviewbyid (r.id.tv_1); TextView TV2=(TextView) Findviewbyid (r.id.tv_2); Layoutparamsparams=NewLayoutparams (Width/3, (int) (Height *0.2)); Tv1.setlayoutparams (params);//to dynamically set the size of a controlTv2.setlayoutparams (params);

android127 zhihuibeijing Screen Fit

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.