What keeps Views/UIViews from being drawn outside their ViewCell/UITableViewCell - c#

I'm trying to replicate Instagram's zoom feature on their list of videos on iOs using xamarin.forms.
I have a xamarin.forms ListView (actually a modified FlowListView) and I've been successful for the most part except for the fact that when I'm zooming, the zoomed view (an AVPlayerViewController) zooms fine but cannot extend beyond the size of the cell that contains it so it gets clipped. The effect is achieved by a simple UIPinchGestureRecognizer and UIPanGestureRecognizer and applying the appropriate Transform/Scale using CGAffineTransform.
You can see the problem here
From what I understand, the clipsToBounds property is what keeps views confined to their parent's frame so I tried:
setting clipsToBounds to false (even though that's supposed to be the default value) in the renderer and recursively to all the views' .Parent properties.
setting it to false in the default ViewCell renderer.
setting Xamarin's IsClippedToBounds to false at the xaml level.
Instagram also seems to blur the background of the zoomed video (as it is being zoomed) which would indicate that they've somehow moved the video view out of the cell and into some other temporary fullscreen view.
So I'm looking for some general guidance; is my understanding of clipsToBounds wrong? What is keeping the view from being drawn outside of its UITableViewCell? Should I approach this from a different angle? I'm at my wits' end, thanks in advance.

Related

Unity UI fixed child size in horizontal layout

I'm trying to build the clone layout of wechat. But I not able to make build the correct alignment for the children inside of Horizontal Layout. The parent of the horizontal layout is ScrollView.
The video link below shows the effect I get for now. The avatar should be fixed. I did tried to apply some others Layout but it's not working very well for me.
https://drive.google.com/file/d/16nSz6x-Ojh_GqrnWFKdJwbYSZ396g8CP/view?usp=sharing
That's happening because your UI anchors are on incorrect position. You need to understand the UI anchor system of Unity first. Take a look at this official article here.

How can I prevent content in a Xamarin Forms ScrollView becoming stuck when the orientation changes?

Say you have a Xamarin Forms ScrollView control with some content.
The content is such that; it fits entirely in the viewport when the device is in the portrait orientation however, it extends beyond the viewport when the device is in the landscape orientation.
The problem
When you rotate the device to landscape and scroll the content to the bottom, then rotate it back to portrait, the content does not reset and cannot be scrolled - it is now stuck half way up the page.
This seems to be a bug in Xamarin Forms as it only happens in iOS and not Android. That said, it could be a while until this is resolved. I'm looking for suggestions on how to prevent/overcome this situation in the mean time? Possibly with a custom renderer?
Here is a solution to reproduce the issue: https://github.com/afalz/ScrollViewIssue
I see you're using a shared project (the Xamarin.Forms). When programming in a IOS project, you can set the ContentSize of your ScrollView to accommodate for the changing of layout (landscape, portrait).
ScrollView scrollview = new ScrollView();
scrollview.ContentSize = new RectangleF(x, y, screenHeight, screenWidth);
You can then use the override ViewDidRotate method and change the ContentSize property.
For your example, I think you'd be best off to implement a method that gets called every time you change your screen layout, just like the ViewDidRotate method, and change the ScrollView.Content.HeightRequest to the new screensize.
I hope this helps. Good luck!

Viewport3D not updating visuals after performing RenderTargetBitmap

Rendering a Viewport3D with a RenderTargetBitmap.Render call seems to cause the Viewport3D to no longer update its visual content. The interactive actions still work though, such a hover-over and clicking.
I've created an example in which I have a viewport which contains a button. I then render the viewport with RenderTargetBitmap. After this render, I try to toggle the visibility of the button but the visuals of the button no longer update which is unexpected. It is however not possible to click on the button as you would expect when it is collapsed. Toggling back the visibility to visible allows me to click the button again so it seems that only the visuals are no longer processed correctly.
It seems that the viewport loses track of the correct buffer it should use and keeps displaying the old version no matter what. I would like the viewport to just keep updating its visuals as it did before the render call, any ideas what I am missing here?
I've uploaded the demonstrator on bitbucket, the sourcefiles can be viewed here:
Sourcecode
The demonstrator is also available as a VS2010 solution:
download solution
If you require any other information please let me know, I'll try to answer your questions as detailed as possible.
I was having a similar issue. After the call to RenderTargetBitmap's Render(), I noticed that, for example, any color changes applied to the visuals within the Viewport were not being displayed. As you state, the interactive actions like clicking, rotating, hover-over, etc. were still working.
Within my application the Viewport being rendered was itself sitting inside (i.e. a child of) a Grid. I found that if, after the call to RenderTargetBitmap's Render() method, I removed the Viewport from and then readded the Viewport to the Grid's 'Children' list, the visuals within the Viewport continued to update as they did before the call to Render().

Resolution for full screen WPF application

Following the guide here, I have created a full-screen WPF application. But I met a problem: the various size & resolution of screens. For example, I want to put several sprites on the screen as buttons; but they are located at different positions in each screen, and even different to what shown in the XAML designer.
I have searched all over without a clue got. How can I fix this problem? (to make the buttons appears the exact place (in the center), and better, help the xaml designer reflect exactly what will happens when the program is running). Any help will be appreciated.
UPDATE: I'm defining my page as a Canvas inside the Window element. Actually I like Canvas more, cause I can easily put my sprites anywhere, not like a grid.
In general, you should not use pixel values in WPF.
Instead, you should layout your content in <Grid>s with rows and columns, and it will automatically expand to fill the screen (based on the alignments and row / column definitions).
Avoid using the canvas. Also, do not rely too much on the designer to build your layout. Using Grids, Stackpanels and/or Dockpanels will give much better results (and scale when resizing your window). For example, if you use only the designer and drag-and-dropp all your elements, the designer often puts huge margins a bit randomly and this will not always scale properly if you resize your window.

C# ListView: ListViewItem offset possible?

I was wondering... I have a WinForms System.Windows.Forms.ListView with a bunch of ListViewItems that I'm drawing using the View.List style. Each ListViewItem has a "SmallIcon" that I fetch from the ListView's SmallImageList.
My problem is that the icons are showing too close to the border on the left. I've tried to change the bounds and the ListViewItem's Position property to no avail.
Is there anyway to have some kind of offset to ListViewItems?
The Win32 listview control doesn't have any setting to increase the space between the icon and the label (in any view, not just List). Setting ListViewItem.Position does nothing when the ListView is in List view.
A low-tech solution would be to simply prefix every ListViewItem's Text value with a single space. Slightly ugly, but oh so easy to do.
If you really want to have pixel level control, you will have to owner draw it. As always, if you are doing anything with a .NET ListView, ObjectListView makes owner drawing your items trivial.
As mentioned already, prefixing the text of all your items with a space is a super simple way to add padding. This has a pretty significant drawback, however. Once you do this, you lose the ability to find items in the ListView by simply starting to type their name while the ListView has focus.
Try adding white space to the left of your small images.
If you're using 16x16 images change to 24x16 for example by adding 8 white (or ListView Background color) pixels to the left.
If you are in ListView View LargeIcons then you can postion the text using item.position
A screenshot would be nice for an example to see exactly what you're after.
Funny thing... the Windows Explorer uses the ListView to display files and folders. i usually run my view in Report or Detail mode. i just switched it to List view mode and see the exact problem that you're describing! Yikes. Might be a bug with the Win32 object and that particular view type!
A quick workaround might be to use a Report style for the ListView with a single column or perhaps implement something yourself. The FlowLayoutPanel in .Net would work very nicely as a starting point for a custom list view.
As you are using the View.List style, I suspect you'll either need to implement some custom drawing or consider padding your images. You could also look at overriding the ListView control and manipulating it's bounds by overriding SetBoundsCore or SetClientSizeCore (or similar).
However, if the ListView were set-up for View.Details view, this could be done using the ListViewItem.IndentCount property:
The IndentCount property can be used
only when the View property of the
containing ListView is set to Details,
and the SmallImageList property of the
ListView is set. Source:MSDN
If you set the StateImageList property you can add a space of 16 px before the icons. I think you can adjust this additional space by loading an image with matching width as first entry into the StateImageList. But I have not tested this.
This thread discusses the opposite problem.

Categories