I'm new to android. I want to ask which layout is best and easy to use in xml files.
I'm confused with constraint layout and linear or relative layout.
Relative Layout:
A relative layout displays its views relative to one another, so order is not that important. You can define the top most view at the end of the layout and provide details to show it on top left. The following attributes are used to define relative layouts:
Position relative to screen: You can align a view relative to screen using alignParentTop, centerHorizontal etc.
Position relative to other views: You can align a view relative to another view using above, below, toLeftOf etc.
Margins: You can provide margins using marginTop, marginLeft etc.
Linear Layout:
A linear layout displays its views next to each other either vertically or horizontally. So, if you define views in a row, they will be displayed one after the other. You need to specify orientation to define whether layout is vertical or horizontal. The following attributes are used to define linear layouts:
Weight: It specifies how much space each view spans relative to others. For example, in an e-mail application, you can give less weight to ‘To’ and ‘Subject’, and more weight to ‘Message’.
Gravity: It defines placement of a view’s contents. For example, if a view spans entire screen, but has only one line of text, then you can decide whether it should be displayed on top, center or bottom.
Layout Gravity: It defines the placement of the view itself.
Related
I am trying to create dashboard edit mode grid with gridstack javscript library.
Here is what I am trying to accomplish which is similar to this Databox platform. This is what it looks like when you edit any of the dashboard to view/edit it in grid mode.
So when I drag the blue border handle and scale the div(or even move with cursor hand) then the around grid(which is background layer with absolute position in reality) is automatically adjusted to match the corresponding div. Like this.
Even if there are multiple widgets there, resizing is working everything perfectly fine.
e.g. if there was any sibling widget then resizing this widget would also resize the sibling widget but can not go beyong 1 * 1 grid which is smallest size there.
Even after resizing both widgets, the background static grid boxes (with yellow border) fills the remaining vacant space similar to what is the concept of dense packing algorithm in css grid.
They are removed when widget is grown and added when it is shrinked.
As it seems super complicated to achieve this, is there any default feature like this with grid-stack library?
So I have an instanced scene that is supposed to be the child of a colour rect in my tree. I want to randomly generate the nodes, but I also want parts of the view to be cut off if the texture no longer is above the main section. I know you can render nodes below their parents, but I don't know if stopping part of them from rendering is physically possible.
In this image I want the bottom circle to remain the same, but the top circle to not show anything above the dark purple box
This is the node tree in the editor
Is there any way to do this directly, or am I gonna have to use a viewport of some variety?
I believe what you want is to set rect_clip_content to true on the ColorRect (or whatever Control). Making invisible any part of its children outside of it.
From Godot's documentation:
bool rect_clip_content
Enables whether rendering of CanvasItem based children should be clipped to this control's rectangle. If true, parts of a child which would be visibly outside of this control's rectangle will not be rendered.
If what you want is the opposite, perhaps you can use z_index to have something render on top, occluding the parts you don't want visible.
There is also a trick you can use with lights (including 2D lights):
Make a light that matches the area you want things to be visible.
Set a custom material that will be transparent by default, but visible on the light pass. The simpler way to do this is to set the light_mode of the material to "Light Only". You could also do it with a custom shader instead.
Making something disappear with light, in 2D, is impossible. In 3D, you can use flags_use_shadow_to_opacity. That is how you make a shadow catcher.
But, there is one more trick: you can use a mask. This should give you full control of when to show or hide things. So, if none of the above solutions works for you, use a mask. I have an explanation in a different answer. See also: How to crop sprite in a non-rectangular form?.
Mighty Mochi Games recently (2022-03-30) made a compilation of the different approaches in video form: Mask Methods Collection - Godot 3.x - 2D
.
Is it possible to have the vtkAxesActor small in a corner of the window?
Here is a image of what I currently got and what I would like to have. The colorful axes are the standard axesActor. But I would like the axes in a corner of the window and only there (bottom left in black). They shouldn't move around the window when the view is rotated. Only around their origin.
Is this possible? And if yes, how?
A possible solution is to put the vtkAxesActor into an orientation widget:
widget = vtk.vtkOrientationMarkerWidget()
widget.SetOrientationMarker(axisActor)
widget.SetInteractor(interactor)
widget.SetViewport(0, 0, size, size)
widget.InteractiveOff()
widget.EnabledOn()
The vtkAxesActor location is functional and it's location has a purpose. The anchor point of the AxesActor is the anchor point of the model. This provides context of where any transformations or translations would be calculated from.
Unfortunately the example of the axisActor in the corner you have proposed would only provide context of the orientation of the model and so not part of the standard options.
I have done my own version of the PropertyCross Demo (provided in their demo section).
The problem I currently face is the size of the "Recent Search" area. While I have a non-scrollable container, I can easily define the preferred height. As the Box Layout adheres to the preferred size, all is well, with the little issue of not being able to scroll it and see more than one result:
recentSearchContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); recentSearchContainer.setPreferredH((int)(this.getContentPane().getHeight() * 0.1f));
Once I set the container to scrollable, the preferred height gets overwritten and takes up as much space as it needs, taking too much space from the BorderLayout Center piece above it.
How to manipulate the preferred size of scrollable components?
You don't manipulate the preferred size. Scrollables take up more space so if you need them to take up a specific amount of space you need to use the right type of layout which in this case might not be border layout...
Border layout gives NORTH/SOUTH elements their preferred height which might not be what you want. You might want a grid layout which will divide the height 50/50. You might want a table layout where you can define the height in percentages etc.
For those who are interested, here is the solution:
Setup a table layout with a single column and as many rows as you need (similar to box layout y axis or border layout which only north, center and south).
Set the table layout to non-scrollable so it defaults to 100% of your screen.
add the components with height % of the screen they should take up.
those components can be scrollable and will still stick to the height constraint!
// inside a form object, setup the layout
TableLayout tl = new TableLayout(3, 1);
tl.setGrowHorizontally(true);
setScrollable(false);
setLayout(tl);
...
// and add stuff to it
add(tl.createConstraint().heightPercentage(15), labelDesc);
add(tl.createConstraint().heightPercentage(50), compGroup);
add(tl.createConstraint().heightPercentage(35), recentSearchContainer);
Works like a charm!
Is it possible to create this shape with two colors in QGIS?
To get this kind of effect, we can use multiple layers on the symbol selector interface. Add in another layer to the symbol (using the plus symbol in the bottom-left corner), set both layers to have a transparent fill and set the outline of the bottom layer to have a wider outline than the top layer. Then set the colours for the two layers accordingly, with transparency scaled down for the bottom layer. Here are a few screenshots, though I've used black instead of white to make it more visible on the symbol selector dialogue:
Note the "outline width" on the bottom layer is larger than that on the top, to let it show through. Hope this helps!