Android5.0 differs from 4.x, and android5.04.x

Source: Internet
Author: User

Android5.0 differs from 4.x, and android5.04.x

Previously developed projects run perfectly in 4.x, but when users upgrade to over 5.0, there is an inexplicable bug. The following are differences summarized in bug modification! (Continuous update)


The general feeling is that after 5.0, programmers have higher coding requirements, not as casual as the 4. X Series (* ^__^ ......


1. The View must be a ViewGroup such as LinearLayout or RelativeLayout. In 4.x, it can be a View. After 5.0, the View settings are invalid.

/*** Set the control relative to the screen height or width * @ param context * @ param view control * @ param rate ratio * @ param orientation for example, set the width and height, set */public static void setHeight (Context context, View view, double rate, int orientation) {WindowManager manager = (WindowManager) context. getSystemService (Context. WINDOW_SERVICE); int width = manager. getdefadisplay display (). getWidth (); int height = manager. getdefadisplay display (). getHeight (); switch (orientation) {case WIDTH: view. getLayoutParams (). width = (int) (width * rate); break; case HEIGHT: view. getLayoutParams (). height = (int) (height * rate); break; case BOTH: view. getLayoutParams (). width = (int) (width * rate); view. getLayoutParams (). height = (int) (height * rate); break; case BOTHWIDTH: view. getLayoutParams (). width = (int) (width * rate); view. getLayoutParams (). height = (int) (width * rate); break ;}}

Related Article

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.