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

Border radius doesn't render the same way as ViewOutlineProvider radius. #728

Open
1 task done
hipczor opened this issue Nov 25, 2020 · 0 comments
Open
1 task done

Comments

@hipczor
Copy link

hipczor commented Nov 25, 2020

Version

0.39.0

Issues and Steps to Reproduce

The sample below creates a rounded border with a background. Since, currently, it is not possible to clip background to its border (#235), I've tried to create a ViewOutlineProvider and set the same radius as I set to the border.

val componentContext = ComponentContext(this)

        val radius = 56 //px
        
        val row = Row.create(componentContext)
            .marginDip(YogaEdge.ALL, 56f)
            .backgroundColor(Color.RED)
            .border(
                Border.create(componentContext)
                    .radiusPx(radius)
                    .color(YogaEdge.ALL, Color.YELLOW)
                    .widthPx(YogaEdge.ALL, 24)
                    .build()
            )
            .clipToOutline(true)
            .outlineProvider(
                object : ViewOutlineProvider() {
                    override fun getOutline(view: View, outline: Outline) {
                        outline.setRoundRect(0, 0, view.width, view.height, radius.toFloat())
                    }
                }
            )
            .child(
                Text.create(componentContext)
                    .text("Border sample")
                    .marginDip(YogaEdge.ALL, 16f)
                    .build()
            )
            .build()

        setContentView(
            LithoView.create(
                componentContext,
                Column.create(componentContext).child(row).build()
            )
        )

This is the result, the radius on the border is not calculated the same way it is on the view outline provider (and any Canvas since I've tried to align it also with an image using Glide image transformer)

image

Expected Behavior

The border should render the radius correctly so it can be aligned with other methods to round edges of other components.

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