Following bug occurs on a fairly new Motorola Defy with Android 11:
I have a weird black bottom bar in my app when my targetSdkVersion
is 22 which disappears if I set 24 as targetSdkVersion
.
The bug does not appear on my Motorola E2 with Android 5.
I'd wish to stay at targetSdkVersion
22 for valid reasons. The app will run on a very low number of known devices at our customer. The phone is locked up in some sort of a kiosk mode. targetSdkVersion
22 doesn't enforce RuntimePermissions
which makes is perfect for the use as kiosk app.
Here's the stripped down build.gradle (:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
//...
minSdkVersion 17
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 22
versionCode 140
versionName "1.4.0 in dev " new Date().format('yyyy-MM-dd HH:mm:ss')
}
}
dependencies {
//We don't plan to switch to AndroidX with our legacy Android apps that were written around API level 19
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Here's the stripped down AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxxxxxxxxxx">
<application
android:name="xxxxx.xxxxApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="xxxxxx.PresetActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateUnchanged"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here's the stripped down styles.xml
(I only have one styles.xml
):
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
</resources>
Stripped down activity code:
package xxxxxxxxxxx.ui.activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import xxxxxxxxx.ui.fragment.PresetFragment;
import android.support.v7.app.AppCompatActivity;
public class PresetActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_container);
// Add fragment the correct way
// http://stackoverflow.com/questions/8474104/android-fragment-lifecycle-over-orientation-changes
Fragment fragment = getSupportFragmentManager().findFragmentById(
R.id.FragmentContainer);
if (fragment == null) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager()
.beginTransaction();
fragmentTransaction.add(R.id.FragmentContainer,
new PresetFragment());
fragmentTransaction.commit();
}
}
}
activity_container.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@ id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/color_background"
android:paddingTop="8dp"
tools:ignore="MergeRootFrame">
<fragment
android:id="@ id/status_bar_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_status_bar" />
<FrameLayout
android:id="@ id/FragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@ id/status_bar_fragment"
android:layout_alignRight="@ id/status_bar_fragment"></FrameLayout>
</RelativeLayout>
CodePudding user response:
The system assumes that your application cannot handle non standard aspect ratio and uses a 16:9 letterbox.
This can be controlled with resizeableActivity :
<activity
....
android:resizeableActivity="true"
If you don't set it, the default value is true if you target API 24 or greater, and false otherwise.