What layout should I use? - xamarin.android

I'm making a clicker game as a school project.
I'm using the Xamarin (Android) project.
What layout should I use for the main screen? It will look like this (buttons):
Main Screen Pic

Based on the design you give, we can use RelativeLayout as the root element.
RelativeLayout is a ViewGroup that displays child View elements in relative positions. The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the RelativeLayout area (such as aligned to the bottom, left of center).
For more information, you can check document: Xamarin.Android RelativeLayout .
For the inner elements, you can decide which layout(e.g. LinearLayout,TableLayout ) to use based on your situation.
Update:
Will Frame Layout work too?
From document FrameLayout, we could find that:
FrameLayout is designed to block out an area on the screen to display
a single item. Generally, FrameLayout should be used to hold a single
child view, because it can be difficult to organize child views in a
way that's scalable to different screen sizes without the children
overlapping each other. You can, however, add multiple children to a
FrameLayout and control their position within the FrameLayout by
assigning gravity to each child, using the android:layout_gravity
attribute.
You can use other layouts, such as the FrameLayout you said, but as far as your design is concerned, RelativeLayout is more suitable.

Related

HorizontalSplitPanel - Adjust the splitter position based on component width

Is there a way to add more than 2 components in HorizontalSplit panel without nesting it?
Splitter position should be based on the space allocated for the component. There is nesting of horizontal split panel but the splitter position is not set based on the component visible space
If you want a separate resizable split area for each of those components, then no, you cannot do that with just one split panel and nesting is indeed the solution. If you are fine with just one split, then you can add a layout instead of a component and just keep inserting more components to the layout.
You can use splitPanel.setSplitPosition for adjusting the split position. If your desired split position isn't static and your contents don't have fixed sizes, you could possibly use a tool like SizeReporter add-on for querying the content sizes. Note that this will undeniably cause some flickering, because you need to add the component to the layout before you can measure its size.
A horizontal splitpanel allows one component on the left and one on the right side.
Nothing more
What do you want to achieve?
If you add two layouts to HorizontalSplit there is nothing stopping you in adding more than one component to those layouts. You can also add new SplitLayouts to existing splitlayouts if you want that.

How to divide the view controller screen?

I am new to sprite kit. Does anyone know how to divide the view controller into two parts. One is fixed and the second one is movable (I mean like two screens)?
You could create a UIView as a container for your whole screen and within that UIView add two SKViews which would be your "two screens" that you could do with as you needed.
You could give them the sizes you require by getting the first views height and width and set the SKViews proportionally based on that size. Such as an SKViews frame would be the parent UIViews height divided by two.
What are you trying to do? You may not need two controllers. You can use an SKNode as a "screen" in many circumstances. I believe it's also possible to put two SKScene into one view.
So, what does the motionless screen do, and what does the movable screen do?
If it's something like a minimap / menu (like Nintendo DS) then you can easily do that with an SKNode.
You don't need two screens to "ignore" the motionless part of the screen... you get the touch inputs every frame--it's up to you what to do with them. In other words, if the user touches the non-moving part of the screen, you can just ignore those inputs.

Custom Collection View Layout like Chanel app

I'm trying to do a custom layout like the Chanel app you can find the app in the Appstore.
https://itunes.apple.com/us/app/chanel-fashion/id409934435?mt=8
I know they are using an UICollectionView, but no clue how to start.
The interaction feels like a tableview mixed with a paginated scroll. When you scroll the elements grow, and the first element position itself at the top.
Start with dragging & positioning just one UIView. See UIGestureRecognizer docs and look for existing examples of movable views. You'll need an UIPanGestureRecognizer to move the view.
Resize the view depending on its Y position.
Create & position an image inside that view depending on the view size using a couple autolayout constraints.
Note that Chanel app has different constants for these constraints. With a minimum view height, one image's top is 80% height, for another image it's 90% height. Make sure you can manipulate constraints from code (I think it's a good idea to create everything from code there, XIBs are not very flexible).
Make the view "anchoring" to certain points (e.g. top = -75%, 0%, 75%, 90% from what I see in the Chanel app) when you stop moving it. Just find the nearest one and animate the view to it.
Once you did it with 1 view, move all your work to an NSView subclass (if it's not yet there) and create a collection of these views.
You can create UICollectionView, but I'd rather do it with a simple NSArray: I actually don't see a reason to use UICollectionView here; it's a very simple structure. Anyway, you write your own gesture recognizer (don't you? I can't see another way) - so what's the point to use UICollectionView? If you want to expand the app functionality some day, UICollectionView will unlikely help you with that. Well, it's my hypothetical approach, you can find another one while working on that.
Position other views while you're moving an "active" view. Do it by hand, without any UIScrollViews.
Write a function that reflects the Y position of the "neighbor" views while you moving one. It should "slow down" to the bottom of screen.

moving image behind label

I have an image on my view, which I add programmatically & and not through storyboards. The image gets animated to move up the screen. At one point it crosses paths with several buttons and labels, which contain important text that gets blocked by the image passing over them. I want the image to move under the labels and buttons so that the text remains visible. Based on this answer IPhone Interface Builder: Z-Index, Z-order of a button, image, ui element, etc?, I tried to use editor => arrange => sendToBack/sendToFront, however, I don't think this is having any effect because the image doesn't appear in the tree of elements in the storyboard. As noted, it gets added programmatically at a certain time. Is there a way to do this?
I believe you can use [view insertSubview:imageView atIndex:0] which will place it behind all other subviews. Depending on what other subviews you have, you may need to increase the index as it controls what is placed over what in the view (lower index will go behind higher index)
As in answer to this question: Difference between addSubview and insertSubview in UIView class
If you're using addSubview:, your view will be placed on top. To control it's depth use either insertSubview:atIndex: (at exact place from bottom) or insertSubview:aboveSubview: or insertSubview:belowSubview: (which places new view above/below another known object in view hierarchy).

Animate View properties by moving other sibling views

I am trying to create an iOS UI where I have a set of subviews arranged as a grid on the UI and on clicking any of them I would like to expand this subview to a larger size. I am able to do the animation to expand this subview but I would also like this functionality such that other subviews nearby are pushed away.
On dimissing, this expanded view it should contract to the original size and bring back the other views to its original location.
I am thinking of a variety of ways to implement this but there are many use cases, and hence I would like some pointers in the right direction?
Does iOS itself provide a functionality by which expanding a sibling view contracts/moves the neighboring one? If not, what other ways are there to implement this?
Toms

Resources