Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24247] Layout behave different than native

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterHazem Khaled
AssigneeUnknown
Created2016-12-16T20:31:26.000+0000
Updated2018-02-28T19:54:59.000+0000

Description

Titanium has a horizontal and vertical layout before iOS stack view, by calculating the position of each child view, it was very good at that time. Since iOS has native support now, thanks UIStackView and very soon iOS 9 will be the minimum iOS supported by Xcode, it's the time to refactor that old code in favor of UIStackView and force autolayout in all apps. At least it's the time now to refactor Android code with LinearLayout. This part very important for RTL applications, with UIStackView and LinearLayout, apps flipping automatically with max 5% effort to optimize switching between both RTL and LTR. Unfortunately till now we need more effort with Titanium.

Comments

  1. Sharif AbuDarda 2016-12-16

    Hello, Can you share an example of the issue you described?
  2. Hans Knöchel 2016-12-17

    Hey [~hazemkhaled], this more an improvement than issue or am I missing something? But anyway, I think it's a great idea we could follow. I'm currently thinking if we should expose the UIStackView as an own API, maybe even with parity with the existing Ti.UI.Android.CardView *or* handle it internally whenever people use a vertical/horizontal layout.
  3. Hazem Khaled 2016-12-21

    @Sharif AbuDarda I'll add example and screenshots to my [RTL guide](https://github.com/HazemKhaled/Titanium_RTL_guide) and update the issue again @Hans Knoechel I'll give it a try titanium and native and return you with different behavior
  4. Joshua Quick 2017-08-15

    The big problem with this is that there are "portability" issues between Android and iOS on how they natively handle layouts. That is, if we were to do this, views would end up being layed-out different between Android and iOS. For example, how Android and iOS handle Ti.UI.SIZE and Ti.UI.FILL conflicts between a parent and child respectively is handled very differently. That is, when the parent is set up to auto-size itself based on the child and the child wants to auto-size itself based on the parent (this is unfortunately a very common scenario in Titanium apps). In this scenario on iOS, the child will be increased in size to fill the parent's parent. On Android, the parent will be shrunk down to just-fit the min size of the child. This is their opposing native behaviors. Another issue is with zIndex handling. iOS does support views with a higher zIndex in the middle of a vertical or horizontal layout. On Android, LinearLayout do not support this. Also, I'm pretty sure an Android LinearLayout doesn't support overlapping views, which is something our Titanium top/left/bottom/right properties support. On Android, I recommend that we keep our custom layout code. We need it to make Android Titanium app layouts behave like iOS for portability reasons. Features such as right-to-left handling in horizontal layouts will have to be implemented ourselves.

JSON Source