[TIMOB-24898] Android: setting view.borderRadius causes backgroundColor alpha to be ignored
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-07-11T13:43:57.000+0000 |
Affected Version/s | Release 6.1.1 |
Fix Version/s | Release 6.2.0 |
Components | Android |
Labels | n/a |
Reporter | Ian Wall |
Assignee | Gary Mathews |
Created | 2017-06-24T04:59:02.000+0000 |
Updated | 2018-08-07T07:00:31.000+0000 |
Description
The below code loosely simulates how I implemented an overlay tutorial in my app using backgroundColor transparency, set via hex triplets. mainview and label represent app content. containerview is an overlay containing tutorial information, and masking view represents a view that 'darkens' the content until it needs to be highlighted. In the example below, it toggles the highlighting by setting the maskingview backgroundColor alpha to either 0 or 90% when you click the view.
Expected result is the alpha of the maskingview backgroundColor changes and the mainview content is visible or masked. Works on both Android and iOS using SDK 5.4.0.GA. Works on iOS using SDK 6.1.0.GA, but not Android. Commenting out setting borderRadius on the maskingview (issue is both at create or runtime) solves the problem on Android.
Steps to reproduce: uncomment the borderRadius setter below, build with 5.4.0.GA on Android. Expected result: clicking on view fades or shows the underlying "Hello". Rebuild with 6.1.0.GA on Android, clicking on view complete hides the underlying view. Comment out borderRadius setter under 6.1.0.GA, works as expected again.
var win = Ti.UI.createWindow({
backgroundColor: 'black'
});
var mainview = Ti.UI.createView({
backgroundColor: "#202020",
width: 200, height: 200
});
var label = Ti.UI.createLabel({
text: "Hello",
width: 50, height: 30, color: "white"
});
mainview.add(label);
var containerview = Ti.UI.createView({
backgroundColor: "#00202020",
width: 300, height: 300
});
var maskingview = Ti.UI.createView({
width: 200, height: 200,
//borderRadius: 6,
borderWidth: 1,
borderColor: "#ff0000",
backgroundColor: "#e6202020"
});
containerview.add(maskingview);
win.add(mainview);
win.add(containerview);
maskingview.addEventListener('click', function(e) {
maskingview.backgroundColor = (maskingview.backgroundColor == "#e6202020" ? "#00202020" : "#e6202020");
});
master: https://github.com/appcelerator/titanium_mobile/pull/9179
FR Passed. PR Merged.
Jenkins tests are failing due to
backgroundColor: null
Reopening to push fix.master: https://github.com/appcelerator/titanium_mobile/pull/9214
Changes are seen in SDK 6.2.0.v20170711090338. Closing ticket.
There is a little bug in 6.2.0.RC when you don't set a
backgroundColor
and apply aborderRadius
it will disable HW acceleration. But if you set the background color to"transparent"
it will keep the acceleration (like it was in 6.1.2.GA) *Code* (sorry it's an alloy project) JSTSS
XML
In 6.2.0.RC the movement of the ListView is not smooth (in 6.1.2.GA it is). When you uncomment the line
backgroundColor:"transparent"
it will be smooth in 6.2.0.RC.[~michael] What's interesting is it's actually the opposite. When
backgroundColor
is not set andborderRadius
is set whilst you are running Android 6.0+. HW-acceleration will be enabled. SettingbackgroundColor: 'transparent'
with theborderRadius
set will disable HW-acceleration (which allows transparency to work). So you are seeing a smoother ListView with HW-acceleration disabled. Android can be temperamental when it comes to HW-acceleration and in your case you are seeing improvements with it disabled. You could try disabling HW-acceleration in your manifest ([read more](https://developer.android.com/guide/topics/graphics/hardware-accel.html))I've put some log in TiUiView (before every disableHWAcceleration() call *output for transparent backgroundColor (smooth scrolling):*
*output for no backgroundColor (laggy scrolling)*
So you are right, it is disabling HW acceleration in both cases. But adding
doesn't make any difference. So it looks like there is something else that is responsible for lowering the performance. In 6.1.2.GA it is smooth in both cases. I'm currently checking
TiBackgroundDrawable
[~gmathews] There is an endless
draw()
loop inTiBackgroundDrawable
! A log indraw()
is called once per ListView item when I set the backgroundColor to transparent. When I don't set it it is called constantly! So its not the HW acceleration that is causing the problem it is a constant redraw! But I'm not sure what is callingdraw()
all the time :)[~michael] Uh oh!! Thanks for finding that, I'll take a look!
Nice, thank you [~gmathews]!
Is it me or it happen again on 6.3.0 for eg: var avatarView = Ti.UI.createImageView({ height:'40',width:'40', borderRadius:20, touchEnabled:false, defaultImage:'/icon/ic_blueUser.png', backgroundColor:'#fff', }); when i add above code to view, in 6.1.2 is shows BOX image, in 6.2.2 it shows CIRCLE image, in 6.3.0 it shows CIRCLE image, i think something is wrong with handling border radius. but when i turn off hardware acceleration (android:hardwareAccelerated = "false") in 6.1.2, 6.2.2 and 6.3.0 it shows circle it happen on s4 mini 4.4.2, but in other android phone it works fine. sorry if this not related to main bug.
Hi, This (or something similar) seems to have come up again Titanium SDK 7.2.0 Real Device: Lenovo A328 - Android 4.4.2 Simulator: Genymotion Google Nexus 5 - 4.4.4 - API 19 - 1080x1920 Steps to reproduce: 1. Build a new clean alloy app 2. Add the following code to index.js 3. Notice the top of the child view gets cut off. 4. To fix - remove borderRadius value and build again and the view will no longer be cut off