16:9 portrait
But screen ratio is not 16:9.
And the left and right sides of the screen are not displayed.
16:9 Landscape
More like a square than 16:9.
18:9 Portrait
1920x1080 Portrait
same as them.
I suspected the camera rotation.
But there was no problem.
Camera rotation was 0 in xyz.
Why?
My enviroments:
Windows10
Unity2020, 2021(After I have this problem in 2020, I upgraded 2020 to 2021.)
build setting: android
I've read pages over pages, but i still have problems with layout for multiple screens.
I have an image 1080 * 300 pixels that occupy nexus 5 screen horizontally, and is aligned on top of layout (a sort of header). Now if i scale it for xhdpi screens (like galaxy nexus and nexus 4), i don't obtain the same result. by follow scale unit, my 1080 px width image in xxhdpi becomes 720 px image. This dimension fit perfectly for galaxy nexus screen (it's gnexus screen width), but not for nexus 4 that is bigger (768 px), so image don't fill all screen width and i have a blank space on his right.
If i try to scale image to 768 px width, it fit for nexus 4 but not for gnex.
I've noticed also when i change virtual device for preview, this error from adt console:
Displaying it with ', , Locale Language ___Region __, Left To Right, sw384dp, w384dp, h640dp, Normal Screen, Short screen aspect ratio, Portrait Orientation, Normal, Day time, X-High Density, Finger-based touchscreen, Soft keyboard, No keyboard, Hidden navigation, No navigation, Screen resolution 1280x768, API Level 19'
What's wrong?
You can use a custom view called ScaleImageView which is written by Maurycy Wojtowicz.
Class is defined like below:
This view will auto determine the width or height by determining if
the height or width is set(exact size or match_parent) and scale the
other dimension depending on the images dimension This view also
contains an ImageChangeListener which calls changed(boolean isEmpty)
once a change has been made to the ImageView
Here is how you are going to implement it.
Create a class named ScaleImageView.java and copy contents of the link above.
In your xml file, create a ScaleImageView, just same like ImageView (the example I am writing below is for filling screenwidth, and scaling height according to that so there will be no empty spaces on right/left)
<com.project.customview.ScaleImageView
android:id="#+id/scaleImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/file" />
If you need to declare and set programmatically in your Activity, it is also the same as using ImageView:
imageView = (ScaleImageView)findViewById(R.id.scaleImageView);
imageView.setImageResource(R.drawable.file);
I have a WebView that always displays in landscape mode. It displays a website that has been set up so that the content is always fully visible (i.e. no vertical or horizontal scrollbars) as long as the user's resolution is at least 800 x 600. If I load this WebView on a tablet that has a resolution of 1024 x 600, I have to scroll vertically in order to see the whole thing (since Android's built-in navigation bar at the bottom takes up 48 pixels of vertical space). Similarly, if I load this WebView on a phone that has a resolution of 640 x 360, I have to scroll both horizontally and vertically in order to see the whole thing. Finally, if I load this WebView on a tablet that has a resolution of 1280 x 800, I don't have to scroll in either direction (which is good), but the website looks too small because there's so much extra space around the 800 x 600 design.
How can I make this website scale to fit on any of these three devices? In other words, keeping in mind that Android's built-in navigation bar at the bottom takes up 48 pixels of vertical space, the tablet that has a resolution of 1024 x 600 should scale the WebView to 92% so that the 800 x 600 design fits and the tablet that has a resolution of 1280 x 800 should scale the WebView to 125.3% so that the 800 x 600 design fits.
I've read about using the CSS zoom property to do the scaling, but have seen problems with this. An example is with the way text gets rendered sometimes. I think scaling the WebView natively rather than with CSS might make it perform better.
You can make sure you won't scroll "sideways" by setting a viewport meta-tag. Scaling it vertically to fit is usually going to be a bad idea - is your layout really sufficiently flexible to handle every aspect ratio on every device? If you simply want do display something "at the bottom" used CSS fixed positioning instead.
My app scales vertically and cuts off right and left edges. How can I achieve the opposite? For example I have 16:9 portrait image. When I launch it on 16:10 screen in portrait orientation, it should fit horizontally and cut upper and lower edges off. Can I achieve that changing Manifest file? Thanks!
I have a device on which I set portrait orientation, but it shows the activity in landscape. The device width is bigger than its height, so it seems to be inverted. What can I do to have this device working like the others?
Note that this device has a keyboard; see this image.