Center childs in linear layout in android - android-linearlayout

I try to do the following: I have a linear layout. So I want to split it in 3 parts (equal parts) for 3 children. So I make weightSum = 3 and every child weight to 1. But there is one more problem - every child is not centralized in its own part ! I try to set layout gravity to the childs, but there is no effect. Is there any solution for this. Warning: I don't want to set gravity=center of the linear layout (this centralized the children, which I don't want and moreover if I remove one of them the effect is not I want).
Thanks in advance.
Also why when I add views in linear layout and set gravity of the layout to center then there is space between the views ? How can I control this or remove it?

Wrap every child of linear layout into a relative layout and then give layout:centerHorizontal = true to each relative layout.

Related

Container and sidebar at right side

I am trying to achieve something, I want a main container and a sidebar at the rightside. which should deal with mobile layout as well, I was unable to find such thing or make it. The blue print is given in the image below. Thanks
BluePtint of what im trying to make
You can create this layout using div's with different ids or classes- your main body(red) could go in a div with class "#mainbody" and your sidebar(blue) would go in another div with class "#sidebar", then you can specify the dimensions in CSS.
Have you checked out a CSS framework like Bootstrap? Bootstrap makes it super easy to specify column widths with their grid system, so instead of having to state px or % width in CSS, you can add the class "col-md-3" to a column for a width of "3". Their system is based on units of 12, where 12 would be a full bar, 6 would be half etc: https://getbootstrap.com/docs/4.0/layout/grid/

Designing linear layout

I am trying to design a layout which is containing 2 textView at the rightside of imageView.
I know that it is easy to design it with Relative layout.
But i want to design it using linear layout.
Please provide some hints or code to do this.
Thank you in advance!
Hint: You can use LinearLayouts in nested way, one inside the other and so on.
Refer to the following image from Developer site
From the image it is clear that for your case you need to create a linear layout inside that create a imageView and a LinearLayout(called linearLayout2). Now Inside linearLayout2 create two textViews.
Visualize the Linear layout with orientation set to horizontal and set layout_weight to each control. A layout weight of 0.5 means a control will take up the left half of the linear layout (50%).

Qt layout not expanding

I have a Qt Widget which has a frame, containg the rest of the widgets.
I only want one of the widgets to expand on maximazing the window, so I've set a max value for the others.
But it will only expand if I set a grid layout to the frame, which messes up the place of the widgets.
How can I solve it?
Do you use any kind of layout ?
Size policy only works if the parent has a layout set.
You can use a combination of different layouts to obtain the desired look, otherwise you will have to calculate the size of the 'expanding widget' yourself in the resize event method of the parent.

CSS grid and nested elements

Imagine you are using a CSS grid system and your page components are divs, snapped to the grid with a border radius.
If you wish to nest such components, the distance between the parent and child component must be at least a column width - right?
What if you want a smaller distance?
What if you want to nest up to 3 or 4 levels?
Any ideas?
Thanks
If you wish to nest such components, the distance between the parent
and child component must be at least a column width - right?
Why are using border radius to line up blocks/columns in a grid? Shouldn't you be using margins?
If you want to line things up in a grid, all grid columns must have a gutter.
What you're looking for in a CSS grid framework looks very much like 1KB Grid.
If you want more flexibility, you can use the Variable Grid System. From what you're proposing, there really isn't a need for you to use a custom grid or make a css grid framework.

flex 4 - layer a component on top of another?

How can I change the z axis of components and put one in front of the other? The new layout property in Flex 4 has changed significantly & now not sure how to do it.
It works the same way that it did in Flex 3. A components Z order is defined by the order in which they are placed as child of their parent. The second child will be in front of the first child, and the third child will be in front of the first and second child and so on.
You can still use swapChildren and swapChildrenAt to change the Z-order of children.
The layout property's value will be an instance of a Layout class; which--in a simple form your measure() and updateDisplayList() methods. IT does not, specifically, relate to moving one component in front of, or behind, another.
On a Flex 4 group, you can use swapElement and swapElementsAt, although I would bet if you were to examine the code you'd find that these are just layers of abstraction over swapChildren and swapChildrenAt.
checkout the new depth property introduced in Flex 4 e.g. see http://www.tink.ws/blog/flex-4-uicomponent-depth/
Maybe this help:
container's depth
you can use depth property of flex containers to define which element can overlap other elements.

Resources