How to change Android application name in Xamarin.Forms?

前端 未结 3 1731
攒了一身酷
攒了一身酷 2020-12-16 12:09

I am working with Xamarin.Forms in Visual Studio For Mac and I have created a very basic Xamarin.Forms application.

I have checked Android and iOS targets. I got 3 p

相关标签:
3条回答
  • 2020-12-16 12:50

    For android make the change in android folder, mainactivity.cs

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

    Fos iOS make the following in change in the info.plist

    Bundle display name to Myappname

    0 讨论(0)
  • 2020-12-16 12:55

    The problem is that you are changing the assembly name of your application, not the name.

    If you want to change the application name in Xamarin.Forms Android you have two options:

    • Go to your MainActivity and change the Label property:

    • Or remove the Label of the MainActivity and add the name in the Manifest.xml via UI or code:


    On iOS you must change it in Info.plist.

    0 讨论(0)
  • 2020-12-16 13:08

    Other answer works fine. But I am adding more details .

    Application name is picked from AndroidManifest.xml file i.e. <application android:label=...., which in turn refers to values>strings.xml file . Do not hard code app name here. Its good practice separate all strings used in strings.xml file.

    strings.xml

    <resources>
      <string name="app_name">App Name</string>
    </resources>
    

    Label property overrides this and sets the app title , apk name to Label value set inside MainActivity.

    Its preferable to delete Label value from MainActivity.cs's assembly directive [Activity (as it overrides this manifest value at debug time) change the value in strings.xml so that its global and consistent.

    0 讨论(0)
提交回复
热议问题