changeset 2575:5beaaa4e9b03

Android: Improve the layout, if an item expands in the opposite direction of the box... Then use MATCH_PARENT... use weight if it expands in the direction of the box.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 21 May 2021 20:28:43 +0000
parents 5b13bb267364
children db097ec28c90
files android/DWindows.kt
diffstat 1 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Fri May 21 19:50:56 2021 +0000
+++ b/android/DWindows.kt	Fri May 21 20:28:43 2021 +0000
@@ -1241,13 +1241,17 @@
                             w = width
                         }
                     } else {
-                        if (width > 0) {
-                            weight = width.toFloat()
-                        } else if (width == -1) {
-                            val newwidth = item.getMeasuredWidth()
-
-                            if(newwidth > 0) {
-                                weight = newwidth.toFloat()
+                        if (box.orientation == LinearLayout.VERTICAL) {
+                            w = LinearLayout.LayoutParams.MATCH_PARENT
+                        } else {
+                            if (width > 0) {
+                                weight = width.toFloat()
+                            } else if (width == -1) {
+                                val newwidth = item.getMeasuredWidth()
+
+                                if (newwidth > 0) {
+                                    weight = newwidth.toFloat()
+                                }
                             }
                         }
                     }
@@ -1256,13 +1260,17 @@
                             h = height
                         }
                     } else {
-                        if (height > 0) {
-                            weight = height.toFloat()
-                        } else if (height == -1) {
-                            val newheight = item.getMeasuredHeight()
-
-                            if(newheight > 0) {
-                                weight = newheight.toFloat()
+                        if (box.orientation == LinearLayout.HORIZONTAL) {
+                            h = LinearLayout.LayoutParams.MATCH_PARENT
+                        } else {
+                            if (height > 0) {
+                                weight = height.toFloat()
+                            } else if (height == -1) {
+                                val newheight = item.getMeasuredHeight()
+
+                                if (newheight > 0) {
+                                    weight = newheight.toFloat()
+                                }
                             }
                         }
                     }