Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLinearLayout.add with weight doesn't work #140

Open
notEvil opened this issue Mar 4, 2023 · 0 comments
Open

PLinearLayout.add with weight doesn't work #140

notEvil opened this issue Mar 4, 2023 · 0 comments

Comments

@notEvil
Copy link

notEvil commented Mar 4, 2023

This

function t(orientation, weight) {
  return ui.newView('text').text(orientation + ' ' + weight)
}

function l1(y, orientation, weight) {
  var linear_layout = ui.addLinearLayout(0, y, 1, 0.09)
  if (orientation != 'vertical') linear_layout.orientation(orientation)
  linear_layout.add(t(orientation, weight), 'name', weight)
}

l1(0.1, 'horizontal', 0)
l1(0.2, 'vertical', 0)
l1(0.3, 'horizontal', 1)
l1(0.4, 'vertical', 1)

function l2(y, orientation, weight) {
  var linear_layout = ui.addLinearLayout(0, y, 1, 0.09)
  if (orientation != 'vertical') linear_layout.orientation(orientation)
  linear_layout.addView(t(orientation, weight), new android.widget.LinearLayout.LayoutParams(-2, -2, weight))
}

l2(0.6, 'horizontal', 0)
l2(0.7, 'vertical', 0)
l2(0.8, 'horizontal', 1)
l2(0.9, 'vertical', 1)

creates a couple of linear layouts in two ways. The first using PLinearLayout.add and the second LinearLayout.addView with explicit LinearLayout.LayoutParams. Labels 1, 2 and 4 are not visible because their width is set to 0, see

LinearLayout.LayoutParams lp = new LayoutParams(0, (int) height, weight);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant