I develop a Xamarin Forms application for a small android device (480x800 4"). The designer has several "devices", but not such a small one - is there a way to add an own device definition?
The styling for multiple device resolutions could make it adaptive.
First, create new resource files small devices. Then create a method to detect the device size. After that set the resource file based on device size. Add styles to each resource file and spply the styles to your XAML. At last, we have styles that better fit the resolution of the devices we are targeting.
For more steps, you could refer to the link below. https://devblogs.microsoft.com/xamarin/styling-for-multiple-device-resolutions/
You could download the source file from the GitHub for reference. https://github.com/CrossGeeks/MultipleDeviceResolutionSample
Related
I'm a UI designer working with a junior app developer.
We are working on an app I gave him the assets and there sizes using Zeplin app, he showed me the app and it was different than was design telling me that Xamarin doesn't use pixels or dpi but using a number without any measurement.
Is there any way to help him as a designer or something he can use to make the program use pixels or dpi.
#Muslem Mohammed
I think as you are an UI Designer, you are aware that how to provide assets for native app development if not please check for below process.
You can provide Android Assets in the form of Mdpi drawable, hdpi, xhdpi, xxhdpi.
And for iOS 1x, 2x and 3x same like native app assets.
And the developer place all those images into respective folder with respect to the platform.
Example: For Android you will be providing 5 kinds of images with same name respect to the folder I mentioned above.
sample.png for respective folders with the resolution, developer place those images into Android specific project.
Then developer place all images under resources and keep in respective folders.
For iOS also provide the images with same name and by applying 1x,2x,3x with sample below,
sample.png, sample#2x.png and sample#3x.png.
Then developer go to iOS project and place all ios images into Resources folder.
And finally developer will place the image control like below,
<Image source="sample.png" />
And this will show up the image in iOS and Android as well.
My company has just started a new development project using Xamarin Forms. The app looks great on most Android devices but on certain devices the whole app appears magnified. The font is huge, icon resolution looks poor and even the device time, connection, battery life, etc looks magnified.
Has anyone come across this before and did you find the cause?
Appreciate the help!
Will
I think that the problem is related to devices performance and it's not related with the app if problem are battery life , connection and device time , but if you talk about some poor UI you need to check your resolution folder in android or if you use default android theme so it will not look good for old android versions
Before developing the android application you should consider the below things.
1. You should take care of DPI mechanism for different device - For UI issues
2. The child hierarchy level should not exceed 4 to 6.
3. You should not create the objects inside the ondraw method.
4. Don't layout the base at all the times.
5. Inside ondraw, don't use any looping mechanism.
I'm developing an app with Xamarin.Android and Xamarin.iOS. I would like to keep my color values (hex, rgb, or whatever) in a common project so that they can be accessed by both the Android and iOS projects. Is there a way to do this? I'm also using MvvmCross so is there a plugin for this? Or is this a bad idea?
I'm going to be using the colors in the Android layout files (.xml files) and back-end code for both platforms.
Is there a way to do this? [Share colors between platforms]
Yes, you can use MvxColor.* (With some limitations)
I'm also using MvvmCross so is there a plugin for this?
MvxColor is available via a plugin on NuGet.
Or is this a bad idea? [Share colors between platforms]
Use Case: I'm going to be using the colors in the Android layout files (.xml files) and back-end code for both platforms.
MvxColor will not work directly in XML. But can be used through bindings or assigning colors via the code behind. Therefore, if you want to use any Android XML design time tools with colors then MvxColor will not work.
I have only written PC programs using C#, .NET, and WinForms, and am new to app development.
I have written a program that uses HTML files (as a type of "form"), that will then be passed to an app, which can then be used to read/record data. I.e.
On the PC, a user creates a HTML "form"
This is loaded onto a mobile device (phone or tablet)
The user can then open the app, and access each individual (or individual copies) a HTML form to read/record data.
This is then transferred back to the PC, and stored.
Now, I'm not too concerned with the transfer between the PC/device, or the storage of the data, or any of that at this point. What I am concerned about is the ability to open/view these HTML files within a single app.
As the program has already been written using .NET and WinForms, it needs to be converted to be used on a mobile device, and I have chosen Xamarin for this purpose. However I only have limited knowledge of this package, so I am not sure if I can achieve this within a single app (i.e. without having to pass it to a separate app to view the HTML files).
So: is there an environment in Xamarin that I can use to view HTML files within my app?
Xamarin.Forms has a WebView class that you can use to display HTML content, so viewing the content is rarely an issue.
Interacting with the HTML content can sometimes be a bit tricky because of the links not conforming to what the app expects. But you can often solve these issues using the WebView.Navigating event handler that will allow you to catch and change the navigation behavior.
Xamarin.Forms's WebView relies on the native UIWebView (iOS) and WebView (Android) and Xamarin.Forms allows you to override the native Renderers. Overriding the native renderer will give you access to the native WebView with full flexibility.
You also have the possibility to completely ignore Xamarin.Forms's WebView and write your own view using native views.
It would probably be smart to test your WinForms app on iOS using Safari and on Android using Chrome as they are using the same rendering engines that will be used in respectively UIWebView (iOS) and WebView (Android)
I want to develop an app for Windows surface tablet and iOS mobile and iPad.
As I am a new user to Xamarin, when I created my first project,it shows 3 projects:-
hello.driod, hello.ios and hello.winPhone.
I have 3 questions based on this:-
How will I be able to write the same code and share for windows 8.1 and iOS?
and whenever I drag and drop the elements to the UI page, will the same elements be copied to both windows and iOS simultaneously or I got to add them seperately?
Currently I dont have a MAC to connect to my PC. Can I write the code and and there while testing it, connect it to a MAC or should it be connected during the whole process?
Please Help!
Using the same code depends on how your structure your app.
You can go the native route where you can share the bulk of your logic by containing it in a shared / PCL project (more on that here), but have platform specific code for your UI.
For example, if you have a cross platform app targeting iOS and Android you would still create the UI in a storyboard for iOS and AXML files for Android. Any code you want to "connect" to your UI would be specific to that platform as you would use the platform APIs. Any code that is not platform specific (i.e., not calling iOS or Android APIs) can go in your shared / PCL project.
Or you can choose Xamarin.Forms which adds a layer of abstraction by allowing you to write the UI in XAML once and have it work on all platforms. The advantage is increased code sharing as now your UI is also shared. The downside is to utilise platform specific features you'll need to implement DependencyService or custom renderers. Read more about Xamarin.Forms here.
As above, it depends. If you are going the native route, then no. If you are going with Xamarin.Forms, then you are using the same XAML code for the UI across platforms, but there is no drag and drop designer.
To build an iOS app you need to be connected to a Mac. You will also need to be connected to a Mac to use the iOS Designer.