Solution Androidautolayout can't fit 18:9 full screen

Source: Internet
Author: User

Android screens more and more as people demand for big-screen handsets


AutoLayout the previous framework for simply adapting screen pixels has a serious problem of distortion

Hongyang's AutoLayout project address has been discontinued.

Https://github.com/hongyangAndroid/AndroidAutoLayout

The following is a width-height ratio thumbnail

Distortion effect left for normal demand right for a full screen


Solution Modify Autolayoutconfig Init method

Match height to width only (AutoLayout inside meta configuration is 1080*1920 16:9 full screen to 18:9)

Source:

public void init (context context) {
        getmetadata;
        int[] ScreenSize = screenutils.getscreensize (context, usedevicesize);
        Mscreenwidth = screensize[0];
        Mscreenheight = screensize[1];
        }


    
Modify to the following code
public void init (context context) {
        getmetadata;

        int[] ScreenSize = screenutils.getscreensize (context, usedevicesize);
        Mscreenwidth = screensize[0];
        Take the width as the datum
        float mdesignrate = 1.0f * mdesignheight/mdesignwidth;
        float screenrate = 1.0f * screensize[1]/screensize[0];
        if (Screenrate > Mdesignrate) {
            mscreenheight = (int) (screensize[1] * (mdesignrate/screenrate));
        } else {
  mscreenheight = screensize[1];
        }


    

This scheme is not very good, sacrificing the AutoLayout of the percentage layout of the features, just relative to solve the problem of distortion, if there is a better solution can mailbox I

275518834@qq.com

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.