Android Wear Horizontal ListView - wear-os

I'm trying to realize this layout in android wear: Timer Custom App. I think this is like a listview with horizontal orientation, but WearableListView doesn't have this attribute.

Try using a GridViewPager and setting negative page margins :
pager = (GridViewPager) stub.findViewById(R.id.fragment_container);
pager.setPageMargins(0, -30);
You can then implement onClick listeners on the fragments to change the current page by just clicking at the right or left of the page like the native alarm app.

Related

MAUI CarouselView: how to imitate swipe effect in code? Swipe animation does not happen

.NET Maui CarouselView. In certain situations I want my app to take the user to the next card automatically. If I update CarouselView.Position or CarouselView.CurrentItem in code behind, it "jumps" to the next card immediately, no animation. Is it possible to imitate user's swipe? Or as a workaround, maybe somehow apply non-native-CarouselView animation manually to the CarouselView. Please advise.
The CarouselView contains a ScrollTo method that will animate the scroll for you. You either scroll to an index or a specific item.
Give your CarouselView a name in the XAML, and then in the code behind call the ScrollTo.
To scroll to an index:
carouselView.ScrollTo(6);
To scroll to a specific item:
var viewModel = BindingContext as MyViewModel;
var item = viewModel.Items.FirstOrDefault(m => m.Name == "TheBest");
carouselView.ScrollTo(item);
These methods have to be called from the code behind, so if you're using a MVVM approach, you'll need to fire an event or command from your VM for your code behind to act on.
For additional info, take a look at the ScrollTo method docs from Microsoft.

Xamarin.Forms MasterDetailPage with part of master visible on detail

I want to push (make visible) little part of master page to detail page like on pictures in links below. Is it possible in Xamarin.Forms?
Before swipe
After swipe
I'll be grateful for help.
Set
<ContentPage NavigationPage.HasNavigationBar="False">
Place a StackLayout or Grid that looks like the side menu shown in your image. Add a tap gesture recognizer to it.
slMenu.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => ShowSideMenu(masterPage)),
});
private void ShowSideMenu(MasterDetailPage masterPage)
{
masterPage.IsPresented = !masterPage.IsPresented;
}
This is possible, but requires quite some work, since you can't access the width of the MasterDetailView directly.
In another post (see How to set width for MasterDetailPage in xamarin forms ) I have described how to change the width of the MasterDetail view.
While implementing that, I came across a behaviour like you want to have, though for me it was an error.
Basically the steps would be
Implement a custom version of the MasterDetail view where you can set up a custom width
Change the width of the master view so it is a bit wider than it should be
Adapt the calculations when collapsing and expanding the view so that they don't collapse the entire width
For instance if your Master View gets a width of 340 and you want the last 40 to show, make sure that when being collapsed it "only" moves by 300

Multiple controls on Xamarin button?

I would like complex button, which has several text elements and which should change their state and color depending on button state.
Unfortunately, I see that Xamarin button has only predefined image and text parameters.
How to have multiple controls inside a button in Xamarin?
Visual state manager(Only XF 3.0+) have three states: normal, disabled, focused which is named "CommonStates", or you can create custom states.Maybe it could help:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual-state-manager
I think you must read more in content view, where you can add labels into stacklayout or grid with your own api bindable property, then use it wherever you want in your code:
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.contentview

NativeScript animated Modal Page

I need Modal Page appears with "slide from bottom and cover (NOT push) current page" transition.
I set parameter animated of showModal method, but nothing changed.
How implement such transition for Modal Page? Android platform.
it's bug github.com/NativeScript/NativeScript/issues/5989
I have kinda hacky stuff, wrapping my elements with AbsoluteLayout and give it a high top value like '800',
and in navigatedTo function make transition animation with the negative value of the top attribute. In your case you would use left attribute and make transition over x.
Another solution that looks better in the UI, adding a custom component that would act as your modal, wrap your page elements with AbsoluteLayout, add your custom component when you need to show your modal, and apply the previous animation hack to it.
Tip: You can set the actionBarHiddin = true if you want to your custom component to overlay the full screen.
Tip: async/await and then would be very useful for the smoothing matters.

Xamarin Forms - Layout Cycle detected. Layout could not complete

I have a xamarin forms page with a listview and a picker. On the changed event of the picker, I populate the listview. On Windows phone, intermittently, I get this exception:
System.Windows.LayoutCycleException: Layout cycle detected. Layout could not complete
Sounds like a timeout issue due to the number of items set in the ItemSource.
I would explicitly set the height value of the ViewCell and the Children of that view cell so that Windows Phone doesn't try to calculate the height for every item
See this Xamarin Forum post for more info:
https://forums.xamarin.com/discussion/41813/layout-cycle-detected-layout-could-not-complete-after-resetting-listview-itemssource

Resources