Я использовал изображение в качестве фона экрана spla sh, оно было изменено для разной плотности пикселей:
hdpi - 480x800 mdpi - 320x480 xhdpi - 768x1280 xxhdpi- 1080x1920 xxxhdpi - 1440x2560
splash_screen. xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@drawable/launcher"/>
</layer-list>
стилей. xml
<style name="AppTheme.Launcher" parent="BaseAppTheme">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="colorPrimaryDark">@color/grey_light</item>
</style>
Он отлично работает на эмуляторе, но на Samsung Galaxy M20, A7, S9 et c (разрешение 2340x1080, плотность экрана xhdpi) внутри выглядит зауженным. Любое решение для этого?
Nexus 4 (xhdpi)
Samsung Galaxy M20 (xhdpi)
AndroidManifest. xml
<activity
android:name="com.demo.app.MainActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.Launcher"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
activity_main. xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_child"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomHolder"
android:fitsSystemWindows="false">
<include layout="@layout/toolbar_tabbar" />
<include layout="@layout/activity_main_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/bottomHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:elevation="@dimen/bottombar_elevation"
android:orientation="vertical">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:menu="@menu/activity_main_drawer" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:adSize="BANNER"
app:adUnitId="@string/admob_banner_id" />
</LinearLayout>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/myDrawerBackground"
android:fitsSystemWindows="true"
app:itemBackground="@drawable/drawer_item_background"
app:headerLayout="@layout/drawer_top"
app:menu="@menu/activity_main_drawer"
android:theme="@style/NavigationViewStyle"/>
</androidx.drawerlayout.widget.DrawerLayout>
activity_main_content. xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main"
app:layout_behavior="com.demo.app.util.CustomScrollingViewBehavior">
<com.demo.app.util.layout.DisableableViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.demo.app.util.layout.DisableableViewPager>
</RelativeLayout>