How do I resolve the distortion that occurs when I switch the portrait to landscape app?

0

Normal view (portrait)

Fortheviewitlooksnormal,asyoucansee,nowwhenIputitinlandscapemode...

I wish the background would not be distorted, as in the image above. For this I would like them to list a way to display another image as background when the app was placed horizontally (landscape) or so that the image I placed did not distort, if there is any size that the android detects, anyway ...

NOTE - ALREADY CREATED AN IMAGE FOR HORIZONTAL MODE, I ONLY DO NOT KNOW THE POSSIBILITY OF PLACING IT TO BE DISPLAYED ONLY WHEN THE APP HAS LANDSCAPE MODE.

    
asked by anonymous 26.12.2016 / 22:12

2 answers

0

There are two possible answers to your question. The first, and to which anyone would respond, is what the @Ramaral quoted.

In quote to his comment, I will summarize as an answer. You will have to create two images, with the same name, but with resolutions appropriate for lang and port . To do this, your setting in /res should look like this:

Drawable-land  
      imagem.png   

Drawable-port
      imagem.png

There's a catch-all when you set up such a setup: you'd have to create two images for each resolution type, which is a bit damaging.

The second answer is the simplest and most compact. You create only one image and use it at any resolution, because the image is self resizable.

The answer comes from a question I asked myself: When and why should we use SVG?

If we use SVG , we only create one file and use it in different resolutions, without losing it. Here's the answer:

  

I've learned to vector "stuff" in Corel Draw, and this business of images does not lose quality is the maximum. (blablabla)

     

From Lollipop (API 21), Android included the class VectorDrawable , to define drawables based on vector graphics. Android Studio 1.4 adds the Vector Asset Studio to make them easier to work with, including an SVG import feature and a new Gradle plugin that generates PNG versions of VectorDrawable at compile time for API 20 and earlier versions. There are also third-party tools for converting SVGs to VectorDrawables . Keep in mind that although the drawables vector can be defined in XML, the file format is not SVG and not all SVG files can be converted successfully.

     

Is it recommended to start a transition from PNG to SVG in the application?

     

According to the documentation , the use of vector characters instead of < in> bitmaps reduces the size of the APK because the same file can be resized to different screen densities without loss of image quality.

     

We have that every library added to a project brings many possibilities and features, but libraries usually contain a large amount of code files and resources, among them, unnecessary resources depending on each type of situation. This creates a kind of residue: applications have a lot of things that are never actually used. More than that, the size of packages are growing at a rapid pace. The point is, we should try to minimize as much as possible

  

ThisimagefoundonWikipediathatbestdescribesthe Scalable Vector Graphics , illustrates the difference between bitmap and vector images. The bitmap image is composed of a fixed set of pixels, while the vector image is composed of a fixed set of shapes. In the image, the scale of the bitmap reveals the pixels when sizing the vector image preserves the shapes.

     

Read the documentation for more details.

    
26.12.2016 / 22:57
0

Yes, it is possible, using configuration qualifiers , which allow you to control how the alternate features based on the characteristics of the current device screen.

Configuration qualifiers are strings that are added to the names of the Android project's resource directories.

In your case you should create a folder named res / drawable-land and put there whatever image you want to use when the device is < > landscape . It should have the same name as that used in portrait mode.

    
26.12.2016 / 22:59