# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1621111577 0 # Node ID 2b4f2929408e0156895a9fadd3067b1a0a10c2b9 # Parent 303f544d14fa95212d3da4b331c39b14d76c4773 Android: Fix issue with specifying static sizes... still some issues. Needed to set the width and height DURING creation of LayoutParams. Some android controls still don't layout properly when forcing sizes. So change to -1 (auto size) in dwtest to work around it for now. diff -r 303f544d14fa -r 2b4f2929408e android/DWindows.kt --- a/android/DWindows.kt Sat May 15 19:11:53 2021 +0000 +++ b/android/DWindows.kt Sat May 15 20:46:17 2021 +0000 @@ -951,7 +951,10 @@ } if (box != null) { - if ((item is LinearLayout) or (item is ScrollView)) { + var weight: Float = 1F + + // If it is a box, match parent based on direction + if ((item is LinearLayout) || (item is ScrollView)) { if (box.orientation == LinearLayout.VERTICAL) { if (hsize != 0) { w = LinearLayout.LayoutParams.MATCH_PARENT @@ -961,50 +964,54 @@ h = LinearLayout.LayoutParams.MATCH_PARENT } } - } - var params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) - // If it isn't a box... set or calculate the size as needed - if (item !is LinearLayout) { + } else { if(width != -1 || height != -1) { item.measure(0, 0) } - if(width > 0) { - w = width - } else if (width == -1) { - w = item.getMeasuredWidth() + if(hsize == 0) { + if (width > 0) { + w = width + } + } else { + if (width > 0) { + weight = width.toFloat() + } else if (width == -1) { + val newwidth = item.getMeasuredWidth() + + if(newwidth > 0) { + weight = newwidth.toFloat() + } + } } - if(height > 0) { - h = height - } else if(height == -1) { - h = item.getMeasuredHeight() - } - // Handle non-expandable items - if(hsize == 0 && w > 0) { - params.width = w - } - if(vsize == 0 && h > 0) { - params.height = h + if(vsize == 0) { + if (height > 0) { + h = height + } + } else { + if (height > 0) { + weight = height.toFloat() + } else if (height == -1) { + val newheight = item.getMeasuredHeight() + + if(newheight > 0) { + weight = newheight.toFloat() + } + } } } + var params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) + // Handle expandable items by giving them a weight... // in the direction of the box. if (box.orientation == LinearLayout.VERTICAL) { if (vsize != 0) { - if (w > 0) { - params.weight = w.toFloat() - } else { - params.weight = 1F - } + params.weight = weight } } else { if (hsize != 0) { - if (h > 0) { - params.weight = h.toFloat() - } else { - params.weight = 1F - } + params.weight = weight } } // Gravity needs to match the expandable settings diff -r 303f544d14fa -r 2b4f2929408e dwtest.c --- a/dwtest.c Sat May 15 19:11:53 2021 +0000 +++ b/dwtest.c Sat May 15 20:46:17 2021 +0000 @@ -1140,9 +1140,9 @@ dw_box_pack_start(hbox, imagestretchcheck, -1, 25, FALSE, TRUE, 0); button1 = dw_button_new("Refresh", 1223L ); - dw_box_pack_start(hbox, button1, 100, 25, FALSE, TRUE, 0); + dw_box_pack_start(hbox, button1, -1, 25, FALSE, TRUE, 0); button2 = dw_button_new("Print", 1224L ); - dw_box_pack_start(hbox, button2, 100, 25, FALSE, TRUE, 0); + dw_box_pack_start(hbox, button2, -1, 25, FALSE, TRUE, 0); /* Pre-create the scrollbars so we can query their sizes */ vscrollbar = dw_scrollbar_new(DW_VERT, 50); @@ -1810,19 +1810,19 @@ dw_box_pack_start(notebookbox8, scrollbox, 0, 0, TRUE, TRUE, 1); abutton1 = dw_button_new("Show Adjustments", 0); - dw_box_pack_start(scrollbox, abutton1, -1, 30, FALSE, FALSE, 0); + dw_box_pack_start(scrollbox, abutton1, -1, -1, FALSE, FALSE, 0); dw_signal_connect(abutton1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(scrollbox_button_callback), NULL); for(i = 0; i < MAX_WIDGETS; i++) { tmpbox = dw_box_new(DW_HORZ, 0); - dw_box_pack_start(scrollbox, tmpbox, 0, 24, TRUE, FALSE, 2); + dw_box_pack_start(scrollbox, tmpbox, 0, 0, TRUE, FALSE, 2); sprintf(buf, "Label %d", i); labelarray[i] = dw_text_new(buf , 0); - dw_box_pack_start( tmpbox, labelarray[i], 0, 20, TRUE, FALSE, 0); + dw_box_pack_start( tmpbox, labelarray[i], 0, -1, TRUE, FALSE, 0); sprintf(buf, "Entry %d", i); entryarray[i] = dw_entryfield_new(buf , i); - dw_box_pack_start(tmpbox, entryarray[i], 0, 20, TRUE, FALSE, 0); + dw_box_pack_start(tmpbox, entryarray[i], 0, -1, TRUE, FALSE, 0); } }