Android Label/Icon - in AndroidManifest/Build options vs MainActivity - xamarin

In a Xamarin project, I can set the Android Label and Icon directly via the Build Options UI - which I believe updates the AndroidManifest.xml file
And I can also set it in code like so above the MainActivity class:
[Activity(Label = "MyXamApp", Icon = "#mipmap/ic_launcher", Theme = "#style/MyXamApp.Splash",
MainLauncher = true,
Does one take precedence over the other, do I need both, which is the correct way?

When you set the icon in Option, it will then be used to automatically generate the manifest for you. This is the default value for the Android project.
When you set the Icon, Label in Activity, it would reset the Icon, Label at runtime.
Normally, we would set our own Icon, Label in Activity. If you do not set it again, it would use the Icon, Label value in AndroidManifest file.

Related

Android Studio and layouts

The Android Studio 3.6 Starts with a Constraint Layout as default when opening an empty activity app. How can I Change it to relative Layout and set is as default maybe.
two ways:
1) select layout name and change to RelativeLayout
2)go to
app->res->layout->right click for new layout resourse ->change in root element to RelaytiveLayout->finish

How to use Font Awesome in Xamarin.iOS?

I am trying to use Font Awesome Icons in my Xamarin.iOS project.
In my Xamarin.Android project it was pretty simple:
I downloaded the Font Awesome WebKit from here
I copied the .ttf-Files of the fonts I want to use in my Assets folder
I create a new Typeface for my TextView with the font and use the unicode of the icon
Code:
var myIcon = new TextView(Context);
var regularFont = Typeface.CreateFromAsset(Context.Assets, "fonts/fa-regular-400.ttf");
myIcon.SetTypeface(regularFont, TypefaceStyle.Normal);
myIcon.Text = "\uf007";
I can change TextColor, BackgroundColor, etc. like a normal text.
My problem is, I can't figure out, how to use Font Awesome in my Xamarin.iOS project. Most tutorials and How-Tos are directed to Xamarin.Forms. I tried to merge many of these approaches, but it failed.
The only approach I found is to draw the .svg-Files with SkiaSharp, but that is no option for my use case.
Add .ttf files in your Xamarin iOS project (I have added it in resources)
Now inside info.plist Add a new key “Fonts provided by application”
Expand the array, and in string value add your fontname (eg: fa-solid-900.ttf) which you have added in your project
Setup Done:
Now Just wherever you want to add fontawesome icon just select font awesome as font family in storyboard but make sure to add text programmatically
SushiHangovers comment leads me to the solution for my problem.
FontAwesome Pro and xamarin.ios only one font can be active
It was not possible to use 3 Font Awesome fonts at the same time in the Designer, but it works when they are used during runtime via code.

IconToolbarItem with Iconize not click event

I am currently developing a Xamarin.Forms application. I am using IconizePlugin. The app is tabbedPage based and on toolbar I'm trying to include icons for some actions.
This is whay I'm getting:
Icons are showing well and in Xamarin.iOS gets the click event, while it is not working in Xamarin.Droid.
I included the corresponding nugets and followed every steps told in documentation and can't archive this. Other iconize controls in Droid are working fine except the IconToolbarItem.
Please help!
The workaround I found was to declare de IconToolbarItem in the c# code instead of xaml. Although I don't know why it wasn't working while on xaml.
Declaring the item li
ToolbarItems.Add(new IconToolbarItem
{
Icon = "fa-plus",
IconColor = Color.White,
Command = new Command(this.addBono)
});

Xamarin The application could not be started

Hi everyones i got a anoying problem:
The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity (MainLauncher = true).
Things i do:
adb uninstall ; nothing happens
try to uninstal app from device: the app dont apeard, even like a fake app whith 0kb
Uninstall Mono Shared Runtine and Api from app
Factory reset
Check in another device
Nothing solve my problem and i dont know who i must do.
Add:
My MainActivity;
[Activity(Label = "AppTecnicos", Icon = "#drawable/icon", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
I found the error (Finally): my app package name started with uppercase.
AppTecnicos.Droid
I changed it to:
appTecnicos.Droid
The application could not be started. Ensure...has a launchable activity (MainLauncher = true).
One Activity in your application needs to be assigned as the MainLauncher otherwise the Android OS does not know the main entry point to app and what to display.
In Xamarin.Android typically this is done via the ActivityAttribute by assigning MainLauncher = true.
Example:
[Activity(Label = "StackOverflow", MainLauncher = true, Icon = "#mipmap/icon")]
public class MainActivity : AppCompatActivity
{
~~~
}
Ref: ActivityAttribute Class
If you are using visual studio and your aplication is a Xamarin.Forms aplication, this could be happening due to a solution configuration problem.
In that case, try to open the solution properties and within the configuration properties section check that your proyect its checked for deploy.

How to make UWP cordova app icon background to match windows theme

The title says it all.
All images in the platforms/windows/images folder are png files with transparent background, but when I build the app package it becomes gray. Like in the image below.
Is there a way to make my cordova UWP app have a dynamic background that matches the windows theme just like "skype" does.
Files in platforms/windows/images directory
SplashScreen.scale-100.png
SplashScreenPhone.scale-240.png
Square150x150Logo.scale-100.png
Square150x150Logo.scale-240.png
Square30x30Logo.scale-100.png
Square310x310Logo.scale-100.png
Square44x44Logo.scale-100.png
Square44x44Logo.scale-240.png
Square70x70Logo.scale-100.png
Square71x71Logo.scale-100.png
Square71x71Logo.scale-240.png
StoreLogo.scale-100.png
StoreLogo.scale-240.png
Wide310x150Logo.scale-100.png
Wide310x150Logo.scale-240.png
UPDATE:
After reading Dave Smits answer I realized that background color on start menu is defined in cordova generated .appxmanifest file. I edited it manually and changed the element uap:VisualElements attribute BackgroundColor to "transparent" and generated package had a background color of current theme as I asked.
Next step is to change that BackgroundColor property from cordova config.xml, because it will be deleted next time cordova decides to generate a new .appmanifest file
in your manifest you define a color too; make this transparent too
to do directly in cordava add this to your config.xml
<preference name="BackgroundColor" value="0xff0000ff"/>

Resources