Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24757] right-to-left floating views

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
Reporterdr@camindo.de
AssigneeUnknown
Created2017-05-29T17:15:10.000+0000
Updated2018-02-28T19:55:15.000+0000

Description

var myWindow = Ti.UI.createWindow({ backgroundColor: '#fff' }); myWindow.open(); var myContainer = Ti.UI.createView({ left: '0dp', top: '80dp', right: '0dp', height: '200dp', backgroundColor: '#ddd', layout: 'horizontal' }); myWindow.add(myContainer); var div1 = Ti.UI.createLabel({ right: '20dp', top:'10dp', width: '100dp', backgroundColor:'#ffeedd', text:'DIV1' }); myContainer.add(div1); var div2 = Ti.UI.createLabel({ right: '15dp', top:'10dp', width: '100dp', backgroundColor:'#ddeeff', text:'DIV2' }); myContainer.add(div2); var div3 = Ti.UI.createLabel({ right: '10dp', top:'10dp', width: '100dp', backgroundColor:'#ccffcc', text:'DIV4' }); myContainer.add(div3);

Comments

  1. Sharif AbuDarda 2017-05-29

    Hello, This is not a bug. For view layout set to horizontal the children are always laid horizontally from left to right. The left and right properties in child are used as padding between the children, and the top and bottom properties are used to position the children vertically. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.View-property-layout. So, with horizontal layout child elements are always set from left to right. Remove horizontal layout from the parent view and calculate and set the right values in the child labels
       var win = Ti.UI.createWindow();
       
       win.open();
       
       var div1 = Ti.UI.createView({
           width : Ti.UI.FILL,
           height : '40dp',
           top : '80dp',
           borderColor : '#ffeedd',
           borderRadius : 10,
       
       });
       win.add(div1);
       var div2 = Ti.UI.createLabel({
           right : '20dp',
           top : '10dp',
           width : '100dp',
           backgroundColor : '#ffeedd',
           text : 'DIV2'
       });
       div1.add(div2);
       var div3 = Ti.UI.createLabel({
           right : '135dp',
           top : '10dp',
           width : '100dp',
           backgroundColor : '#ddeeff',
           text : 'DIV3'
       });
       div1.add(div3);
       var div4 = Ti.UI.createLabel({
           right : '245dp',
           top : '10dp',
           width : '100dp',
           backgroundColor : '#ccffcc',
           text : 'DIV4'
       });
       div1.add(div4);
       
  2. dr@camindo.de 2017-05-29

    Thanks for your answer. But in this case my views are not floating - e.g. if I have 50 div's. Can you please register this as a feature request. We have 2017 and apps in the arabic world have to work in a different way.
  3. dr@camindo.de 2017-05-29

    As a workaround I will calculate absolute positions and use eventHandler "postlayout" to check if device has been rotated. But it's a complex calculation. An attribute "rtl" additional to "layout" would help in future. Thanks for your investigation!
  4. Sharif AbuDarda 2017-06-01

    Ok, sure. I will forward this to engineering for future improvement.

JSON Source