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

Test MarginLayoutParams vs LinearLayout.LayoutParams #422

Closed
wants to merge 1 commit into from

Conversation

swankjesse
Copy link
Contributor

No description provided.

@swankjesse
Copy link
Contributor Author

This test shows that LinearLayout.LayoutParams has different behavior from ViewGroup.MarginLayoutParams when both are used in a LinearLayout with Paparazzi.

I believe both types have the same behavior on real devices.

It’s unlikely that the root cause of this is Paparazzi; it’s much more likely that layoutlib has the original bug.

I’m unsure of next steps here. We could report it upstream to layoutlib? And we should advise developers to use LinearLayout.LayoutParams when configuring a LinearLayout as that works consistently across platforms.

@swankjesse
Copy link
Contributor Author

swankjesse commented May 4, 2022

I found the root cause of the difference in behavior. It’s not layoutlib vs. real devices; instead it’s an API-level distinction.

From View.java:

/**
 * Prior to N, some ViewGroups would not convert LayoutParams properly even though both extend
 * MarginLayoutParams. For instance, converting LinearLayout.LayoutParams to
 * RelativeLayout.LayoutParams would lose margin information. This is fixed on N but target API
 * check is implemented for backwards compatibility.
 *
 * {@hide}
 */
protected static boolean sPreserveMarginParamsInLayoutParamConversion;

@swankjesse
Copy link
Contributor Author

No action to take in Paparazzi on this.

@swankjesse swankjesse closed this May 4, 2022
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

Successfully merging this pull request may close these issues.

None yet

1 participant