微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin闪屏,带版本号

如何解决Xamarin闪屏,带版本号

enter image description here

这是我的xaml代码


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <color android:color="#fcaf17"/>
    </item>
    <item android:top="50dp" android:bottom="50dp" android:left="-100dp" android:right="-100dp">
        <shape android:shape="oval" android:innerRadius="5dp" >
            <gradient android:type="radial" android:gradienTradius="300dp" android:startColor="#ffd60b" android:endColor="#ffb41a"/>
        </shape>
    </item>

    <item
        android:left="75dp"
        android:right="75dp"
        android:width="250dp"
        android:height="70dp"
        android:gravity="fill_horizontal|center_vertical">
        <bitmap
            android:tileMode="disabled"
            android:gravity="fill"
            android:src="@drawable/app_logo" />
    </item>
</layer-list>

我的问题是如何在android和ios中的图像下方添加版本标签/文本。预先感谢!

解决方法

关于 Android ,您可以参考this sample在布局中添加TextView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_gravity="center"
        android:background="@drawable/splash_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <ProgressBar
        android:id="@+id/progressBar1"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <TextView
        android:text="Version Label"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="match_parent"
        android:layout_height="47.0dp"
        android:textColor="#FFA500"
        android:id="@+id/textView1"
        android:gravity="center" />

</LinearLayout>

然后 SplashActivity.cs 可以为TextView设置版本值:

TextView textView = FindViewById<TextView>(Resource.Id.textView1);
textView.Text = "V " + this.ApplicationContext.PackageManager.GetPackageInfo(this.PackageName,0).VersionName;
//or set a specified value
//textView.Text = "V 2.0";

效果:

enter image description here

关于 iOS ,您可以在 LaunchScreen.storyboard 内添加一个UILable

enter image description here

在这里,我为UILabel设置了最终版本值。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。