grid-layout

N-by-2 grid, and if the last row has only a single column, center it

我与影子孤独终老i 提交于 2019-12-02 05:41:02
问题 I want to have an N-by-2 grid like this, in which some elements (columns) might be set to display:none based on run-time factors, making the number of rows and columns unknown in advance at the design time. So it could look like this: 1 2 3 4 5 or 1 2 4 5 (3 is missing) or 1 3 (2, 5 is missing) 4 (4 is the last column) I want the last element to be always centered. I make each div .col-xs-6 to make the grid N-by-2. What can I do to make the last column to always be in center? Last column,

Qt: update pixmap grid layout with 2d array values

北战南征 提交于 2019-12-02 05:13:38
I am undertaking a game using a combination of c++ in visual studios 2010 and Qt 4.7 (both windows). The game is a clone of battleship and is console input based. I have created my gui how I want it to look, and on the Qt side in Qt designer, my gui consists of a grid layout 10x10, using labels to hold pixmaps of game cells: I have painstakingly named each label to represent its position in the 2d array (ie. fleet map => F_00 => F[0,0] => F[i],[j] ). I can manually choose what pixmap I would like to display using the properties editor, but I would like something dynamic. I use an update

Java: Can't apply Gridlayout to a Jscrollpane. Get Get java.lang.ClassCastException

倾然丶 夕夏残阳落幕 提交于 2019-12-02 04:48:07
I use a Gridlayout to place 4 elements in one Line. First I had a JPanel and everything worked fine. For the case that the number of lines get to big and I have to be able to scroll down, I changed it a bit. Now I have my JPanel with one JScrollPane added on it. I used the same code, now I just add the elements to the viewport of the Jscrollpane , but now I get this exception Get java.lang.ClassCastException: layout of JScrollPane must be a ScrollPaneLayout: at javax.swing.JScrollPane.setLayout(Unknown Source) and I dont know exactly why. Why shouldnt be Gridlayout's be unknown for Jscrollpane

GridLayout with view dynamic get row/column

时光总嘲笑我的痴心妄想 提交于 2019-12-02 04:04:55
I just followed this tutorial , to create a custom View as an item of a GridLayout . That's my CustomView public class RowView extends View{ boolean touchOn; boolean mDownTouch = false; private OnToggledListener toggledListener; int _IdRow = 0; int _IdColumn = 0; public RowView(Context context, int Rows, int Columns) { super(context); this._IdRow = Rows; this._IdColumn = Columns; init(); } public RowView(Context context) { super(context); init(); } public RowView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public RowView(Context context, AttributeSet attrs, int

Add space before and after first and last grid items

心不动则不痛 提交于 2019-12-02 03:27:50
问题 My question is identical to this question, but the given solution does not work. Here is a codepen of what I'm working with. I've tried two different approaches, both of which are almost correct but not quite: 1. Applying ::before and ::after psuedo classes to first and last grid items Unfortunately when I add margin-left and margin-right properties to the first and last grid item respectively, it adds the space to the grid items as if it were padding space and not margin space, otherwise

Add space before and after first and last grid items

自古美人都是妖i 提交于 2019-12-02 02:31:46
My question is identical to this question, but the given solution does not work. Here is a codepen of what I'm working with. I've tried two different approaches, both of which are almost correct but not quite: 1. Applying ::before and ::after psuedo classes to first and last grid items Unfortunately when I add margin-left and margin-right properties to the first and last grid item respectively, it adds the space to the grid items as if it were padding space and not margin space, otherwise this works fine. 2. Applying ::before and ::after psuedo classes to grid container It will not allow me to

Bootstrap grid with different image heights

隐身守侯 提交于 2019-12-02 00:01:49
I'm working on a dynamic album art grid with CSS and Bootstrap 3 and everything works fine, when all images are scaled 1:1. But when an image occurs that is not scaled like that, my grid breaks. Here is a screenshot of my problem: Screenshot But what I want is The code to generate the grid looks like this: <div class="row"> <div class="col-md-6 panel panel-default" v-for="result in results"> <img src="{{ result.art }}" /> <strong>{{ result.title }}</strong> <br /> from <strong>{{ result.album }}</strong> <br /> by <strong>{{ result.artist }}</strong> </div> </div> I'm using Vue.js for this

How to fit image to frame keeping aspect ratio and center in thumbnail list

妖精的绣舞 提交于 2019-12-01 21:21:17
问题 I want to show list thumbnail box as data grid. each thumbnail image has to be placed in frame with specific width and height (for consistency) as follow: <div class='frame'> <img src='img1.jpg' /> </div> <div class='frame'> <img src='img2.jpg' /> </div> By setting image width and height to frame, images change to wrong aspect ratio and for smaller size image than frame, they are stretched to frame (I don't want to effect smaller size image). How can I fit image within frame without effecting

Can you set a permanent size for a JPanel inside of a JFrame?

这一生的挚爱 提交于 2019-12-01 20:37:56
My current problem is that I have a JFrame with a 2x2 GridLayout. And inside one of the squares, I have a JPanel that is to display a grid. I am having a field day with the java swing library... take a look Image Java is automatically expanding each JLabel to fit the screen. I want it to just be those blue squares (water) and the black border and not that gray space. Is there a way I can just set the size of that JPanel permanently so that I don't have to go through changing the size of the JFrame a million times before I get the exact dimension so that the gray space disappears? I also would

How to fit image to frame keeping aspect ratio and center in thumbnail list

我与影子孤独终老i 提交于 2019-12-01 19:49:06
I want to show list thumbnail box as data grid. each thumbnail image has to be placed in frame with specific width and height (for consistency) as follow: <div class='frame'> <img src='img1.jpg' /> </div> <div class='frame'> <img src='img2.jpg' /> </div> By setting image width and height to frame, images change to wrong aspect ratio and for smaller size image than frame, they are stretched to frame (I don't want to effect smaller size image). How can I fit image within frame without effecting aspect ratio of image. my next question is how can I set image to center of frame whatever the size is