Xamarin формирует пользовательский экран spla sh - PullRequest
0 голосов
/ 26 января 2020

На моем экране Spla sh я хочу разместить версию приложения для Android и iOS внизу enter image description here

Ответы [ 2 ]

0 голосов
/ 28 января 2020

Чтобы создать собственный экран Spla sh, попробуйте это

Создайте SplashScreen.a xml в вашем каталоге ресурсов в проекте Droid

`<?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
          .
          .PLACE YOUR IMAGE CODE HERE
          .
         />
    <TextView
        android:id="@+id/AppVersion"
        android:text="App-Version - "
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="40dp"
        android:layout_marginBottom="40dp"
        android:textColor="#FFFFFF"
        android:textSize="12"
        android:background="@android:color/transparent" />
</RelativeLayout>`

Затем создайте файл CS для ваш экран spla sh в проекте Droid

    namespace Blue.Test {
    [Activity(Theme = "@android:style/Theme.NoTitleBar", MainLauncher = true, NoHistory = true, ScreenOrientation = ScreenOrientation.Portrait)]    
    public class SplashScreenActivity : Activity {
        protected override void OnCreate(Bundle savedInstanceState) {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SplashScreen);            
            FindViewById<TextView>(Resource.Id.AppVersion).Text = $"Version {PackageManager.GetPackageInfo(PackageName, 0).VersionName}";            
        }
    }
}

Не забудьте установить MainLauncher = true & NoHistory = true в вашей сборке

0 голосов
/ 27 января 2020

Обычно для создания экрана spla sh мы используем ресурс drawable. Он не может вводить текст, вы можете сгенерировать stati c изображения с интересующим вас текстом.

Способ, которым мы использовали для создания экрана spla sh.

Resource> Drawable> Create splash_background. xml

<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <color android:color="#000000"/>
  </item>
 <item>
   <bitmap
    android:src="@drawable/pink"
    android:tileMode="disabled"
    android:gravity="center"/>
  </item>
</layer-list>

Ресурсы> значения> добавить стиль в стили. xml

<style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="android:windowBackground">@drawable/splash_background</item>
</style>

Изменить тему в MainActivity.

[Activity(Label = "SplashScreenDemo", Icon = "@mipmap/icon", Theme = "@style/MyTheme.Splash", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

enter image description here

Подробнее о IOS можно посмотреть по ссылке. https://medium.com/@thesultanster / Xamarin-НОАС sh -screens-правый-полосная-3d206120726d

...