1

Hello, I have a picture with is in square format and I want to mask it like in the example below on the right side at loading of the view. I am very new in appcelerator and I don't know what is the best way to proceed, since all the different resolution sould be support. Right now we have the header as a view and the following feed as a seperated view. We are using alloy, but of course also we can add classic code to it.

enter image description here

Should I create a PNG imgae with have the part of the face as open part? But than I see some problems with different solution.

Any hint would be very much appreciated.

1 Answer 1

4

You could either place two views on top of each other:

a square one with the image aligned to the right side and one with borderRadius: half width/height on top of it moved to the left (center of the circle is on the left line of the square).

Or if they don't align correctly you could use this script
https://github.com/falkolab/com.falkolab.maskedimage with https://github.com/GeraudBourdin/Ti.SvgView/ to create a SVG mask

Update:

Here is a working version without any extra plugin:

index.tss

"Window" : {
    backgroundColor: "white"
}
"#view_bg" : {
    right: 0,
    width: 160,
    height: 160,
    backgroundImage: "/images/default.jpg",
    top: -20
}
"#view_head" : {
    width: 160,
    height: 160,
    backgroundImage: "/images/default.jpg",
    top: -20
}
"#view_circle" : {
    width: 80,
    height: 80,
    right: 40,
    borderRadius: 40
}
"#view_box" : {
    right: 0,
    width: 80,
    height: 80
}

index.xml

<Alloy>
    <Window>

        <View id="view_box">
            <View id="view_bg"></View>
        </View>
        <View id="view_circle">
            <View id="view_head"></View>
        </View>

    </Window>
</Alloy>

enter image description here

Change view_bg and `view_head' top value to align the image inside the cutting views

1
  • added an example
    – miga
    Commented Dec 4, 2017 at 19:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.