MainActivity.java
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.ViewGroup.LayoutParams;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.view.WindowManager;
import android.view.View;
import android.view.Window;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView txt = new TextView(this);
txt.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT
));
txt.setText("Hello, world!");
LinearLayout lay = new LinearLayout(this);
lay.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT
));
lay.addView(txt);
setContentView(lay);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
versionCode="1"
versionName="0.1">
<uses-sdk android:minSdkVersion="21"/>
<application android:label="test">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
And I get
Where are the three nagivation buttons ? Why is there a fullscreen icon at bottom right ? Is this navigation bar or something else ? How do I get the app window sandwiched between status bar and navigation bar ?
I tested this on Xiaomi Redmi Note 5 Pro (APILEVEL=28).
After much head banging I figure out that app runs in some "compatibility mode" if targetSdkVersion is too low (may be relative to device apilevel). targetSdkVersion >=24 fixed it for me. Shitty documentation Android :/