I am running into a problem with layout groups in Unity that I do not understand and was hoping for some insight.
My goal is to create a 12 button keypad contained in the bottom half of the screen of a mobile device that would look something like this:
123
456
789
-0-
My approach to this was to use a vertical layout group to first split the screen into a top half and bottom half and then use another vertical layout group on the bottom half to make 4 rows. Each row would have a horizontal layout group with 3 buttons. The problem I am running into is that when I add the 4 rows into the bottom layout group (bottom half of the screen) it starts to automatically expand and ends up taking up much more than just the bottom half of the screen. In the end I just want the 12 buttons contained in the bottom half of the screen and I keep toggling and playing with child control and force expand but do not understand why the automatic resizing is happening. Any insight would be greatly appreciated, thank you, and wishing you a great day
Just use grid layout group that would solve the problem
I think you can use grid layout and make the fixed column count and get the center layout, and use this github https://github.com/mrbeardy/BeardyGridLayout, I get it from unity forum
Hope you like it :)
Related
I created a brand new Swift Cocoa Macos project, and placed a NSTableView. I auto layouted it, and then ran the app, and got this result: https://i.stack.imgur.com/bQmQD.png
If I shrink the window down just a tiny bit more, then the horizontal scroll bar will appear.
Steps to reproduce using XCode 12:
Create a new Macos App using storyboards
Add a NSTableView, and in interface builder place it on the top left corner. Proceed to make it the same size of the window.
Add 4 constraints on all sides of the NSTableView so that it is the same size as your window, even if you resize the window.
Add 3 more columns and name your columns whatever you want.
Proceed to run the app, shrink the right border of the window, and you can see, you can shrink your window past the point of last column, so it's possible that the last column is obstructed and the H-Scrollbar is still not visible. It only shows when you shrink the window even more.
Desired Behavior:
As soon as I resize the window so it can now no longer fit all the columns, the horizontal scroll bar appears.
Is there anyway to solve this, like a hidden setting?
I've tried reproducing this 4 times, and I was successful.
The fix is to set Column Sizing of your table view to your desired settings.
I am trying to use the auto size classes from the storyboard on xcode 7 to position UI elements in a controller. The problem that I'm running into is that when I try to use the "Add missing constraints" function (located at the bottom right corner of the console), it positions my UI elements correctly except for the last elements (pictures describe better). The first image below shows the storyboard file where I just want 3 buttons (stacked above eachother) to be the same width and length to be on the top right corner of any screen.
However, when I add constraints and run the simulations, it seems like the top two buttons are positioned correctly with the correct length and width but the third button is out of place (image below).
So my question is, am I forgetting a step to make all buttons position themselves? Or should I try to convert everything to a percentage and place UI elements based on the percentage of the screen (if so, how would I go about doing that)?
I've also tried adding another blank button (removing the button label) underneath the 3rd button and adding constraints like that but it didn't work for me. Let me know if you have any suggestions, thanks!
In you case, Autolayout the constraints you need to give to UIButton is 4 constrains.
Leading
Trailing
Width
Height
If you miss any of them, then surely you will get an error. So, what's your error is?
To the third UIButton, you have not given the height, while to the above two buttons you have given.
So, just remove the bottom constraint of UIButton and give the equal height to above UIButton.
FYI, never use Add Missing Constraints without any confirmation from your side.
Update:
Check this video to remove trailing or leading margin:
http://sendvid.com/1h8deg18
You can actually see the solution in action if you use the Preview screen while setting up your auto layout constraints. I just created a similar view and buttons and stepped through the process. I coloured the buttons and named them to make things obvious.
I added the three buttons. At this point, none of the buttons show up in the preview.
I then setup the auto layout constraints for Button1. If you want the buttons anchored to the top right, then you don't need to worry about the leading constraint. You need width, height, top, and trailing.
Now Button1 will snap to it's position in the top right corner of the preview screen.
Now do the same thing for Button2. Set width, height, top (vertical space to Button1), and trailing.
Button2 will now snap into place in the preview.
Now the same thing again for Button3. You anchored the first button to the top right of the screen. Then Button2 to the bottom of Button1 and the right edge of the screen. Then again for Button3. You could also align the edges of the 2nd and 3rd buttons, if you prefer that to trailing space.
Now you'll see in the preview that your buttons are correctly positioned, regardless of device.
As long as you specify height and width for each button, you don't need to worry about the left edge or the bottom edge of the screen at all. They each know to "stick" to the top right and they know what size to be.
** Note: If you're not familiar with the "Preview" option...
With your storyboard open, hold Option and select storyboard again to get another copy of the storyboard on the right side. Highlight the view controller you are interested in on the left side. On the right side, select the Preview option as shown below.
Now you have your storyboard and the preview side by side, so you can see the exact impact of any auto layout changes you make. You can also add or remove devices to the preview.
Is there anyway this doesn't happen?
I have a label that adjusts to its content but if I put it inside a group I'm not allowed to scroll, or even if I put a table inside a group (the group not reaching the page dots) I can't scroll.
You could define a spacing between the picture and the text so that the dots have black background. Look at the activity app how they do so the dots won't be in the way. However the dots seems to always be there if you have a page based app.
WatchOS is still limited on its UI customisation. Your approach is correct but we just can provide so complex layouts yet (Table inside group with bottom margin). I'm sure WatchOS 3 will bring new additions.
I've been seeing this UI technique quite often at Dribbble, mostly demonstrated on iPhone as timeline, and I am really wondering if it's possible to do so on Android. The idea is to exploit scrollbar, make it activate each row it is passing.
Consider these schematics of a list of contact.
The first one is the list (photos on the left side, names on the right) split roughly in the middle with scroll track.
The scrollbar cannot expand and has to be smaller than the smallest row. I believe it is possible to produce this kind of arrangement by combining two listviews and make them roll together.
The second one shows the screen when scrolled and when the scrollbar moves to the second row. After it stops, the second row will expand its height. All hidden elements there like address, phone, etc will show up. Also, the moment the scrollbar leaves the first row / hits the second, the first row will toggle off. It will shrink and remove all elements except name.
I have been thinking about this scenario and one key question in this technique is whether the scrollbar has the ability to activate the row it hits. The only tool I know in regard to scrolling is onScrollListener but I wonder if it's sufficient. Does anyone have any insight into such scenario ?
Thank you in advance.
I've been seen something similar to this in lots of applications. Some of them are just using ListView with design tricks to look like that, others with custom views or something else. The idea which I have in my about this implementation is using two Fragments: left and right which are placed in one FragmentActivity. Left Fragment will be your image holder, where for example you will have a ListView or some other view depending on your choice which will communicate with the Right Fragment and when LeftFragment's ListView stop scrolling, fire an event to RightFragment's ListView to scroll to position 5 for example and expand that item. Not really sure if it's the best option and if it will work properly as you want, but that's the first idea which I can think of to do some implementation like this.
Hope this help you find the right answer.
I want to create a custom panel/layout and it's seeming pretty impossible at this point. I need the components to start in the upper left corner and stack downward until they fill the panel vertically, then wrap to the top of the next column and so on until they eventually fill the screen and create a horizontal scrollbar. After an entire day of trying I've decided it's only possible by abusing GWT (and I assume the whole web browser) adding crippling complexity and terrible performance. Please let me know if I'm missing something and layout like this is possible. Thank you!
Lame solution: Have a small (almost invisible) AbsolutePanel where every string is displayed within a div and measured (getClientWidth/height()). Then each panel can calculate it's size based on the strinsg, borders, padding, etc. it contains. Once each panel knows it's size, they can be layed out relative to the sizes of the other panels in the contianer.
Check out FlexTable, which allows you to specify the row,column for the widget to be added