comparison android/DWindows.kt @ 2681:c1482518b643

Android: Fix weight based layout problems. To use weight, the width/height needs to be set to 0. So if we are in a situation where we can use weight... meaning the layout is in the correct direction, and we have a valid weight then set the weight and force the width or height to 0.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 25 Oct 2021 11:29:34 +0000
parents c90b2d7057c8
children 856d3c8b559f
comparison
equal deleted inserted replaced
2680:1888d0a08365 2681:c1482518b643
1729 val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h) 1729 val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(w, h)
1730 1730
1731 // Handle expandable items by giving them a weight... 1731 // Handle expandable items by giving them a weight...
1732 // in the direction of the box. 1732 // in the direction of the box.
1733 if (box.orientation == LinearLayout.VERTICAL) { 1733 if (box.orientation == LinearLayout.VERTICAL) {
1734 if (vsize != 0) { 1734 if (vsize != 0 && weight > 0F) {
1735 params.weight = weight 1735 params.weight = weight
1736 params.height = 0
1736 } 1737 }
1737 } else { 1738 } else {
1738 if (hsize != 0) { 1739 if (hsize != 0 && weight > 0F) {
1739 params.weight = weight 1740 params.weight = weight
1741 params.width = 0
1740 } 1742 }
1741 } 1743 }
1742 // Gravity needs to match the expandable settings 1744 // Gravity needs to match the expandable settings
1743 val grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL 1745 val grav: Int = Gravity.CLIP_HORIZONTAL or Gravity.CLIP_VERTICAL
1744 if (hsize != 0 && vsize != 0) { 1746 if (hsize != 0 && vsize != 0) {