I have a XAML design in Xamarin android and I want to use it in Xamarin forms.
How could I do that?
this is my XAML code in Xamarin android:
<view xmlns:android="http://schemas.android.com/apk/res/android"
class="mono.samples.notepad.LinedEditText"
android:id="#+id/note"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dip"
android:scrollbars="vertical"
android:fadingEdge="vertical"
android:gravity="top"
android:textSize="22sp"
android:capitalize="sentences"
/>
This is not XAML, this is XML. There is no direct way to support Android XML layouts in Xamarin.Forms (which makes sense as they couldn't work on iOS). You may try to do it with some custom renders, but those will work only on Android.
I have a XAML design in Xamarin android and I want to use it in Xamarin forms
How could I do that?
Android XML and Xamarin Xaml are not the same, they are both different specs of XML and cannot be used in place of each other.
This is my XAML code in Xamarin android:
That is XML and not XAML as you read above, also I have suggested a duplicate above see if that works for you or not
Related
I've converted a project from Xamarin to .Net MAUI. MAUI has many issues, but one of the most annoying is the fact that HorizontalTextAlignment set to Center is not working in Android. For labels that are only a single line the regular HorizontalAlignment is working, but for multiple line labels it is not a working solution:
In the screenshot the two header labels are centered using HorizontalAlignment on the VisualElement, but for the longer text below this is not working. Event though the label element is centered, the text inside is not center aligned.
Does anyone have a solution?
P.S. HorizontalTextAlignment is working in iOS, and it is also working in my Android emulator when I manipulate it in Hot Reload.
Turns out this was an issue because I upgraded a xamarin project to Maui. Somehow in the android mainifest the value android:supportsRtl="true" is then not set on the application element like this:
<application android:networkSecurityConfig="#xml/network_security_config" android:icon="#mipmap/icon" android:label="YourAppName" android:supportsRtl="true">
Thanks to #ewerspej
How to add the animations on the Splash-Screen in react-native. I have an ImageView on the Splash-Screen. I want to add the pulse effect on the ImageView or any other animations. I don't find any solution. please help me to do this. thanks in Advance.
code -
<ProgressBar
android:id="#+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:indeterminate="true"
android:theme="#style/progress"
/>
<ImageView
android:id="#+id/splashlogo"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:src="#mipmap/myihalogo" />
Try using react-native-lottie for your animations in Splashscreen. Ive achieved that and it renders quite beautifully. Basically a JSON file which is the animations and that needs to be rendered.
Hope it helps. Feel free for doubts.
At first, I have searched many articles about changing ios's LaunchScreen.storyboard with lottie animation. However, Xcode enforces that LaunchScreen.storyboard should be static screen. So, I inserted animation code after static launch screen loading. Maybe, launch screen is essential, because it is loading screen for initial loading resource in ios. If you remove the launch screen, then ios app shows black or white screen at first loading.
Remove launch screen, Xcode 7
If you looking for animation launch screen in react native, i would suggest looking into this package.
https://www.npmjs.com/package/react-native-lottie-splash-screen
It implements animation splash screen using airbnb lottie files. Also, I apply this for multiple react native projects and it worked well.
Have a nice day!
I have been trying to create a Xamarin Forms App using Prism that works on both phones and tablets.
For the tablet layout I'm trying to create something similar to the draft image below while still reusing the Pages/ViewModels from the phone.
What I have tried:
Using a TabbedPage where each Tab contains a MasterDetailPage. There are two issues with this solution:
Xamarin only recommends using a MasterDetailPage as the root page
I managed to implement this "solution" but probably due to the reason above the xaml of the pages inside the MasterDetailPage don't bind correctly to their ViewModels.
Using a TabbedPage in which each Tab contains a Page divided in two parts which have a ContentView:
This solution works, but I can't reuse the Page from the Phone version directly on the layout.
I did try using Prism Partial Views to implement this solution, but I think the parent Page needs to contain the ViewModel that is going to be used by the ContentView which wouldn't work in this scenario (because it's going to contain two View Models).
Not sharing the Pages/ContentViews/ViewModels between phone and tablet:
This solution works, because I can implement the MasterDetailPage with ContentViews but there's is no code being shared for pages/views that basically do exactly same thing so it's really not ideal.
Any idea on how I can implement this layout while still sharing the Views and View Models between the Phone and Tablet implementations?
Note: This app is for Android, iOS and UWP using Xamarin Forms 3.4 and Prism 7.1
I need to make a picker like this in the picture below:
What you see is a TimePicker and I took it just to give you an example. I would like to have one with about 200 numbers on the left and 100 on the right (for example). How can I do it in a Xamarin.Forms PCL project?
The first problem you'll face is that the picker control you see here is a native iOS control. The Xamarin.Forms TimePicker is basically not a physical control in itself but it translates to a native control on each platform. That's why it will look different on Android and UWP devices because they provide their own picker controls, as seen in the picture below.
Now, if you're ok with the controls looking different, you could use custom renderers to modify each native control or even replace them to provide the functionality you need. I thought I'd outline the basic steps for you to get you started:
Create a new Xamarin.Forms control called CustomPicker or something.
Create custom renderers for each platform.
On iOS, you can use the UIPickerView and specify numberOfComponents, numberOfRows and the data source.
On Android, you might want to use a 3rd party control since by default, there are no scrolling picker controls like the one on iOS. WheelPicker looks promising.
On UWP, you might be able to work something out using the PickerFlyoutBase. I have limited knowledge on the platform but you should be able to find something quite easily.
As you can see, it's going to be quite an effort to get the scroll picker working on each platform.
Edit: You could also look into native embedding, which lets you embed native controls into Xamarin.Forms app's pages.
Native Embedding
Embedding native controls into Xamarin.Forms
We've developed a two-column picker for Xamarin.Forms (Android and iOS).
Sample:
https://github.com/HorusSoftwareUY/MaterialDesignControlsPlugin#materialdoublepicker
Screenshots:
Android
iOS
We added this control to MaterialDesignControls NuGet (https://www.nuget.org/packages/Plugin.MaterialDesignControls/), where you can find other interesting controls with the material design look and feel.
Contributions are welcome!
I have a simple Progress Bar where IsIndeterminate="True". It's working fine in WP7 but not in WP8. All I see is one dot that doesn't scroll. I've read how the Progress Bar was included in a Toolkit which I should've used in WP7 for performance issues which I didn't (ooops) but running the app in WP8 shows just 1 dot on the screen. I've upgraded the project to WP8 as apparently the Progress Bar within the SDK is the best one to use yet I still have the problem. My xaml is as follows:
<ProgressBar HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" IsIndeterminate="True"/>
Here is an image showing which reference package the Progress Bar is using from the Toolbox:
https://skydrive.live.com/redir?resid=93AA9A941DD84E76!3185&authkey=!AJOdQz3YPV8xEtY&v=3
Could I possibly be referencing a package that has an older implementation of the Progress Bar?
Any help would be great.
I found the problem. It was because I had my own copy of CustomThemeResources which had a WP7 definition of ProgressBar. I removed it and it works.