У меня определен следующий экран spla sh (spla sh. 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="@color/colorGold"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/Banner2"/>
</item>
</layer-list>
Это стиль. xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">false</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name ="Theme.AppCompat.Light.NoActionBar" parent="ThemeOverlay.AppCompat"/>
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
Это мой манифест:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="OML_Android.OML_Android" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" />
<service android:name=".SignalRSrv" android:label="Messenger" android:enabled="true"></service>
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<activity android:name=".activities.MainActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Экран spla sh вообще не отображается, ничего. Я скопировал экран spla sh xml из поста здесь на stackoverflow, и я занимался этим уже пару дней и не добился нулевого прогресса. Чего мне не хватает?
* Обновление *
Достигнут прогресс благодаря @Dipankar Baghel, теперь появляется экран spla sh, но приложение вылетает с unhandled exception
, мой код активности:
using System;
using Android.App;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;
using Android.Content;
using Acr.UserDialogs;
namespace MyAndroidApp
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true, NoHistory = true)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
// reset theme prior to loading layout
SetTheme(Resource.Style.AppTheme);
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
Android.Widget.Button MyButton = FindViewById<Android.Widget.Button>(Resource.Id.button_ok);
UserDialogs.Init(this);
MyButton.Click += (sender, e) =>
{
Context context = this.ApplicationContext;
Intent intent = new Intent(this, typeof(Logon));
intent.SetFlags(ActivityFlags.NewTask);
StartActivity(intent);
Finish();
};
}
}
}
Это код макета:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/Banner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView1" />
<Button
android:text="Ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button_ok" />
</LinearLayout>
Не так много в макете, но я получаю ошибку:
`Невозможно создать экземпляр действия ComponentInfo {My Android .MyAndroid / My Android .My Android .activities.activity_main}:` `
* Обновление *
Обновлен код манифеста.