-
Notifications
You must be signed in to change notification settings - Fork 38
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
All compose screenshots now have transparent background #598
Comments
@pedromfmachado @OptIn(ExperimentalRoborazziApi::class)
@Test
fun captureComposeLambdaImage() {
captureRoboImage(
roborazziComposeOptions = RoborazziComposeOptions {
background(
showBackground = true
)
}
) {
Text("Hello Compose!")
}
} |
I've added this to the release notes. |
Thanks for the suggestion, @takahirom! In this case, because we're not defining the background color within Would it make sense to allow a different activity class to be passed instead of forcing the usage of |
Just FYI and if someone is facing the same problem, we decided to use composeRule.setContent(composable)
composeRule.onRoot().captureRoboImage(...) rather than |
I think it would be good to provide a |
I'll find some time to create a PR soon, sure! |
@takahirom I'm assuming this should probably be made part of the rule? We are having a somewhat related problem in that when we use this type of test after upgrading AGP to 8.7.3 (this seems to apply to roborazzi 1.34+ haven't tested further back)
We're now getting the built in action bar on ComponentActivity, and for some reason that is overlayed over our content. I'm assuming this would also apply to people using createComposeRule as well, since that's essentially the same thing as what I found a simple workaround is to create an AndroidManifest.xml in your
Another option is to change the activity altogether by using the |
Thank you for letting me know. It seems that SDK 35 doesn't provide padding for the ActionBar, which is causing the overlapping issue. The same problem is occurring in NIA. I found that we need to adjust the theme to resolve it. However, I didn’t know that this could be done by placing the AndroidManifest in the |
I have filed the issue. |
I'm considering adding this kind of workaround to Roborazzi. Line 116 in 0f7ad42
![]() |
I think it is necessary to use window rendering to display shadows. However, I'm not sure about Compose and the current situation. |
I think this workaround doesn't work because the View is a window here, and the window has the action bar. |
I think we can show warning or something at least. |
Thanks @takahirom . Given that this is an sdk 35 problem, that opens up other alternatives, such as adding the following to the robolectric.properties file
or doing that in the @config:
|
Thank you for providing alternatives. I'm considering adding this workaround. However, using the view's draw method doesn't capture the background, resulting in a transparent background. Despite this, it might be a better experience than having the action bar overlap issue. |
What if you add the proposed theme android:theme="@style/Theme.AppCompat.Light.NoActionBar" to the theme of the RoborazziTransparentActivity? Or there is a problem with the manifest merging? |
Or alternatively in @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Request features before setting the content view
Window windowToUse = getWindow();
windowToUse.requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
}
|
@sergio-sastre ![]() |
I meant the workaround in this PR. I have currently no computer where I can check it though, but I see on my phone that the new screenshot has no shadow? |
Ah, I see what you mean. I have a reason for using this approach, but I’ll think about it a bit more and get back to you tomorrow. |
@pedromfmachado I apologize for the confusion. I believe the RoborazziComposeActivityThemeOption is still necessary for |
Hey @takahirom, thanks for clarifying, I was not on-par with the discussion yet. 🙂 I was not able to do it so far, but will create a PR in the next couple of days. |
Thanks for the support, @takahirom, I think we can close this now! |
Hey there 👋
In one of the latest releases, 1.35.0 to be precise, the introduction of this line seems to override the application theme.
+ setTheme(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen)
This makes most of our tests fail because they're now transparent instead of following the colors defined by the theme applied in our application class. I've created a workaround to manually apply the desired theme to all our Roborazzi screenshot tests, but would definitely like to move on to a more robust solution.
Is this intended behaviour? I'd be glad to contribute with a fix if you have any idea how to better deal with it! 🙂
The text was updated successfully, but these errors were encountered: