MAUI: Splash screen with 2 logos

Sreejith Sreenivasan 876 Reputation points
2024-09-05T14:54:04.02+00:00

I am trying to create a splash screen with 2 logos, one on the sender and one as a footer. But I didn't get such type of implementation in MAUI. Is there any way to do it on MAUI?

So I tried platform level integration like below for android.

Created splash_screen.xml under Platforms/Android/Resources/layout folder.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/icon1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/icon1" />

    <ImageView
        android:id="@+id/icon2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/icon1"
        android:layout_centerHorizontal="true"
        android:src="@drawable/icon2" />
</RelativeLayout>

Added icon1 and icone2 under Platforms/Android/Resources/drawable folder.

Added theme on AndroidManifest file under application tag.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application 
        android:allowBackup="true" 
        android:icon="@mipmap/appicon" 
        android:roundIcon="@mipmap/appicon_round" 
        android:supportsRtl="true"
        android:theme="@style/SplashTheme">
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
</manifest> 

Added styles.xml file under Platforms/Android/Resources/values folder and added below code.

<resources>
    <!-- Splash screen theme -->
    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@layout/splash_screen</item>
    </style>
</resources>

Finally on the MainActivity added below code:

public class MainActivity : MauiAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        // Set the custom splash screen layout
        SetContentView(Resource.Layout.splash_screen);
    }
}

While running I getting the below exception:

Java.Lang.IllegalArgumentException: 'No view found for id 0x7f08014b (com.companyname.marianconsecration:id/navigationlayout_content) for fragment NavigationRootManager_ElementBasedFragment{f1d86d4} (a90f9cb5-b73f-4ac2-9767-c8bb9b057cb7 id=0x7f08014b)'

6ddAePBM

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,390 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,316 Reputation points Microsoft Vendor
    2024-09-06T06:07:00.84+00:00

    Hello,

    For android 12, android use the SplashScreen Api to show the splash screen. It only customizes these parts: icon, window background, exit animation.

    Creating custom layout and setting SetContentView(Resource.Layout.splash_screen); as the splash Screen is deprecated in android.

    If you want to add a splashscreen in MAUI, you can refer to this document: Add a splash screen to a .NET MAUI app project

    By the way, duplicated thread in SO https://stackoverflow.com/questions/78952510/splash-screen-with-2-logos

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Vicente Gerardo Guzmán Lucio 0 Reputation points
    2024-09-05T15:22:04.41+00:00

    Try this:

    1. Make styles.xml Build Action AndroidResource
    2. In AndroidManifest.xml in the <manifest> tag added this lines of code:xmlns:tools="http://schemas.android.com/tools" android:theme="@style/AppTheme" tools:replace="android:theme"
    3. In MainActivity.cs replace the Theme attribute property like this: [Activity(Theme = "@style/AppTheme"....)]

    Regards!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.