Category: "Xamarin"
Loading Images from Xamarin Forms
Even the UI I built is very simple; I need to load some icons in the UI. I have used navigation page. After I had navigated two pages, then I got an exception, OutOfMemoryException. That is because Bitmap Decode is used a lot of memory. I found we should avoid using:
Code
img.Source = ImageSource.FromFile("test.jpg"); |
We should use the images in the embedded resources
Code
img.Source = ImageSource.FromResource("advgen.test.jpg"); |
Please change the properties of the image file:
Then the problem will solve.
ZXing.Net.Mobile in Xamarin got a black screen
I started to build a library management system for small organisations. This system doesn't require a pc at all. It will works in any iOS and Android devices. It used a camera in the device as a bar scanner. I used an open source framework ZXing.Net.Mobile to do that. I found when I fire the scanner activity, it got a blank back screen. I initialized the framework
Code
MobileBarcodeScanner.Initialize (Application); |
And I gave the camera permission in AndroidManifest.xml, that still got a blank screen.
After I read the document from ZXing.Net.Mobile, it need the flash light. After I gave the flashlight permission, it works.
Xamarin without Mac Host Agent
I just downloaded the new version of Xamarin last week. In the old time, I need to install a mac host agent and ran it every times. That is not very good. I found the new version can build the ios app without that Mac Host Agent. They use SSH remote login to build the app. You only have to enter "remote login" in the spotlight search, then enable remote login in sharing windows. Then that is!
However, I found my iOS device still need to connect with my mac book. If they can do the debug redirect to my windows laptop, then that is great!
Please consider this before WebView in Xamarin Form
Recently, I used the WebView control in Xamarin Form a lot recently. WebView required you to set HeightRequest. If you did not set HeightRequest at all, it won't display at all. That is not a deal, when the WebView has fixed height. However, if you want the height of WebView based on its html content, that will be very hard. You need to write a custom renderer to do that. Xamarin forum has some examples for this purpose.
Missing class.jar in AppCompat folder
After I upgraded Xamarin Forms 2.0, I got an error about missing class.jar under a local folder about AppCompat library. I tried to remove and add Xamarin Forms Library. The final solution is deleting the whole AppCompat library under the local folder