How to fix black bars in Unity2D android game - android

I am making an android game, but when I build the apk and run it on my mobile then it shows me the black bars on the side. The game is in landscape mode, and the camera is in a perspective mode in Unity. How do I fix it?

Player Settings -> Android -> Resolution and Presentation
Set Aspect Ratio Mode to Custom
Set Up To value to 2.2 (or even larger).
For legacy versions,
Android >= 8.0, add android:maxAspectRatio to unity activity
<activity
android:maxAspectRatio="2.2"
android:resizeableActivity="true" />
Android < 8.0, add android.max_aspect to application tag
<application>
<meta-data android:name="android.max_aspect" android:value="2.2" />

Related

Android 13 - Landscape orientation are not actually landscape

In android-13 devices, am facing issue with playing video within the exoplayer. when user rotates them devices video player will be set to full screen. but in this case rotating device can changes orientation but showing app in portrait mode only (whole page)
Expected: rotating device should fill the screen as like Android 12 and previous versions
Tried
android:name=".ui.fullscreenVideo.VideoPlayerActivity"
android:exported="true"
android:configChanges="orientation"
android:screenOrientation="userLandscape"
but issue not fixed (
When user rotate them mobile, video activity also want to get rotated like previous android 12 and below versions
The problem is Android-13, showing portrait screen mode in landscape orientation
We are experiencing same issue in android 13 android:screenOrientation="locked"
I changed the setting to default/nosensor to resolve the issue currently.
android:name=".MainActivity"
android:exported="false"
android:configChanges="orientation|screenSize|keyboard|locale|keyboardHidden|uiModel"
android:screenOrientation="locked"

How to remember last screen orientation setting in android

I have a android 6.0.1 tablet. My activity is here using following orientation settings:
<activity
android:name=".MainActivity"
android:screenOrientation="sensorLandscape"
android:label="#string/app_name"
android:windowSoftInputMode="adjustResize|stateHidden"
android:configChanges="keyboardHidden|orientation|screenSize|uiMode">
When i turn tablet into 180 degree application activity rotate but problem is that when i turn on and off screen using power button on tablet while tablet is in 180 degree, application took few second to rotate. This was not happing in older android version. Is there any android activity setting which i can use to keep remember last screen orientation and keep it same either tablet screen turn off and on ?
Simply use this in onCreate of your activity to disable rotation of activity when screen turn on and off:
((KeyguardManager)getSystemService("keyguard")).newKeyguardLock("keyguard").disableKeyguard();

Android black bar below status bar. What is it?

Android 7.0
After installing my app and hockeyapp app I have weird black bar under status bar. What did it? How to fix it?
It sounds like you are reffering to the Samsung S8 device.
Inside the Application tag in your manifest, try adding the meta data for max aspect ratio.
<application ....
.... >
<meta-data android:name="android.max_aspect" android:value="5.0"/>
....
....
</application>
Most devices have rectangular screens whose width is fairly close to their height, ranging from the 4:3 ratio of a traditional television screen to the now-common 16:9 ratio. However, in some situations an app might run on a device with a more extreme aspect ratio.
An app can declare the maximum aspect ratio it is able to support. If the app runs on a device with a more extreme aspect ratio, the system automatically letterboxes the app, leaving portions of the screen unused so the app can run at its specified maximum aspect ratio.
The Samsung S8 has one of these "extreme" aspect ratios, so it must be specified that you support them. Why this is not by default, I don't know
You should be able to overcome this if you target API 24 and above. Otherwise, try setting the max aspect ratio to something greater than the recommended minimum of 2.1.
Note: You do not need to set a maximum aspect ratio if an activity's android:resizeableActivity attribute is set to true. If your app targets API level 24 or higher, this attribute defaults to true. For more information, see Configuring your app for multi-window mode
Android documentation about the issue can be found here

Configuring screen orientation on Android

I am developing an Android app with Cordova, I use this line in AndroidManifest.xml in order to force a landscape:
android:screenOrientation="landscape"
And it works, but the problem when you flip your phone over 180* the landscape will stay reverse, like this:
Make it android:screenOrientation="sensorLandscape" instead.

My tablet's orientation is 180 degrees (upside is down)?

When developing the app it looks great on my virtual devices.
But when trying it on my real tablet it displays the whole app upside down!
Can I change the orientation by 180 degrees somewhere in the android settings?
Can I change my code slightly to display the app in 180 degrees?
Please note that I am using api8 (android 2.2)
You can set the screen orientation of the activity in the AndroidManifest.xml file
e.g
<activity
.
.
android:screenOrientation="reverseLandscape"
/>
You can use other options see the documentation
I realize the question is about 2.2, however this valuable piece of code (2.3+) handles both orientations of landscape inside your manifest:
android:screenOrientation="sensorLandscape"

Categories

Resources