fix: colors
This commit is contained in:
parent
94632a47ee
commit
e8793d669f
3 changed files with 14 additions and 67 deletions
|
@ -1,15 +1,8 @@
|
|||
package mw.gri.android;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.view.Display;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import com.google.androidgamesdk.GameActivity;
|
||||
|
||||
public class MainActivity extends GameActivity {
|
||||
|
@ -28,49 +21,10 @@ public class MainActivity extends GameActivity {
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
findViewById(android.R.id.content).setBackgroundColor(Color.BLACK);
|
||||
findViewById(android.R.id.content).setPadding(0, 0, 0, getNavigationBarHeight());
|
||||
int navBarHeight = Utils.getNavigationBarHeight(getApplicationContext());
|
||||
// int statusBarHeight = Utils.getStatusBarHeight(getApplicationContext());
|
||||
findViewById(android.R.id.content).setPadding(0, 0, 0, navBarHeight);
|
||||
}
|
||||
|
||||
public int getNavigationBarHeight() {
|
||||
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
return windowManager
|
||||
.getCurrentWindowMetrics()
|
||||
.getWindowInsets()
|
||||
.getInsets(WindowInsets.Type.navigationBars())
|
||||
.bottom;
|
||||
} else {
|
||||
Point appUsableSize = getAppUsableScreenSize(this);
|
||||
Point realScreenSize = getRealScreenSize(this);
|
||||
|
||||
// navigation bar on the side
|
||||
if (appUsableSize.x < realScreenSize.x) {
|
||||
return appUsableSize.y;
|
||||
}
|
||||
|
||||
// navigation bar at the bottom
|
||||
if (appUsableSize.y < realScreenSize.y) {
|
||||
return realScreenSize.y - appUsableSize.y;
|
||||
}
|
||||
|
||||
// navigation bar is not present
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Point getAppUsableScreenSize(Context context) {
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Point size = new Point();
|
||||
windowManager.getDefaultDisplay().getSize(size);
|
||||
return size;
|
||||
}
|
||||
|
||||
public Point getRealScreenSize(Context context) {
|
||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getRealSize(size);
|
||||
return size;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="yellow">#FFFEF102</color>
|
||||
<color name="yellow_light">#FFFEF102</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
|
@ -1,17 +1,13 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Main" parent="Theme.AppCompat.NoActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<style name="Theme.Main" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/yellow</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
|
||||
<item name="android:statusBarColor">?attr/colorPrimary</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
|
||||
<item name="android:navigationBarColor">?attr/colorPrimary</item>
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
</style>
|
||||
</resources>
|
Loading…
Reference in a new issue