Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15099] Android: borderRadius does not adhere to defaultunit

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-03-25T21:55:20.000+0000
Affected Version/sRelease 3.1.2
Fix Version/s2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.2.3, Release 3.3.0
ComponentsAndroid
Labelsmodule_views, parity, qe-testadded
ReporterFokke Zandbergen
AssigneeSunila
Created2013-09-05T09:23:21.000+0000
Updated2016-09-09T16:38:04.000+0000

Description

The borderRadius property does not adhere to the default unit set in tiapp.xml. Both borderWidth and borderRadius only accept Number, so it's not possible to workaround by explicitly setting the unit. Like most other dimension-related properties (except fontSize as far as I know) borderWidth *does* use the default unit.

To reproduce

Create a new app

Replace the code in app.js by:

    var w = Ti.UI.createWindow({
        backgroundColor: 'white',
        modal: false
    });
    var v = Ti.UI.createView({
        backgroundColor: 'red',
        borderRadius: 150,
        width: 300,
        height: 300,
        borderWidth: 100,
        borderColor: 'black'
    });
    w.add(v);
    w.open();
    

Run the app on both iOS and Android and the result will be like screenshots 1 and 2.

Now set the default unit to dp by adding this to the tiapp.xml:

    <property name="ti.ui.defaultunit" type="string">dp</property>
    

Run the app on both platforms again and the result will be like screenshots 1 and 3. As you can see because of the DPI of the tested device the border radius is about half of what we expected.

Attachments

FileDateSize
1-ios.jpg2013-09-05T09:23:21.000+000039970
2-android-px.png2013-09-05T09:23:21.000+000019508
3-android-dp.png2013-09-05T09:23:21.000+000019648

Comments

  1. Viktor Korol 2014-02-01

    Please fix this issue
  2. Sunila 2014-02-03

    Use the default unit for radius. https://github.com/appcelerator/titanium_mobile/pull/5310
  3. Viktor Korol 2014-02-25

    Please merge this fix.
  4. Vishal Duggal 2014-03-25

    New PR's master - https://github.com/appcelerator/titanium_mobile/pull/5521 3_2_X - https://github.com/appcelerator/titanium_mobile/pull/5524
  5. Paras Mishra 2014-03-26

    borderRadius responds to the default unit defined in tiapp.xml as dp borderRadius is rendered same for both android and iOS platform. Verified the fix, hence closing the issue Environment used: Device : Google Nexus 5, Android Version: 4.4.2 Device : iPhone 5s , iOS version : 7.1 SDK: 3.2.3.v20140325145222 CLI version : 3.2.3-dev OS : MAC OSX 10.9.2 Alloy: 1.3.1 ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.2.3.201403250634 titanium-code-processor: 1.1.0 XCode : 5.1
  6. Abdoulaye Siby 2016-09-09

    Guys, this issue is not solved. Or if it was, then here it is crawling back in from the deads. I am using SDK 5.3.1 and it exists also on SDK 5.4. We have even tried to pass the value using something similar to the following ...
       borderRadius: isAndroid ? require('alloy/measurement').dpToPX(40) : 40
       
    ... but it has an erratic behaviour from one Android to another. The result is exactly similar to the screen capture provided by Fokke Zandbergen.
  7. Abdoulaye Siby 2016-09-09

    Wow, that is another bug here in the jira site. It destroyed a simple javascript line that was supposed to look like ... {color:#8eb021}borderRadius: isAndroid ? require('alloy/measurement').dpToPX(40) : 40{color}

JSON Source