Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23974] Android: Add property to release space when hiding an object

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-10-06T15:28:08.000+0000
Affected Version/sRelease 5.5.0
Fix Version/sRelease 6.1.0
ComponentsAndroid
Labelsandroid, community, notable, property, visible
ReporterMichael Gangolf
AssigneeHans Knöchel
Created2016-10-02T09:57:50.000+0000
Updated2017-12-18T18:52:26.000+0000

Description

On Android you can set 3 visible values: visible, invisible and gone. Currently gone is not supported in Titanum. With this setting you can free the space an object has when hiding it. The screenshot shows two vertical layout views with the first three elements hidden. On the left side is the normal behaviour; on the right side I've used gone instead of invisible (the four bottom boxes move up). The property is called hiddenBehavior and can control the behavior when hiding a view. When you set it to true and call hide() it will either release the space (new) or retain the space (default). Default value is still Ti.UI.VIEW_INVISIBLE so it behaves like normal when you don't change it. When you show the object again it will take up the previous space again *Current workaround to release the space:* Hiding: save the current object height, hide the object, set the height to 0. Showing: show the object, set the height to the saved value. *Parity?* Not sure if this is possible on iOS. Perhaps someone else can add this part

Attachments

FileDateSize
Screenshot_2016-10-02-11-45-55.png2016-10-02T09:50:05.000+000025411

Comments

  1. Michael Gangolf 2016-10-02

    PR: https://github.com/appcelerator/titanium_mobile/pull/8458 in the documentation I've put 6.0.0. Not sure if its 6.1.0 already :)
  2. Michael Gangolf 2016-10-02

    Changed the property name to hiddenBehavior with two constants Ti.UI.HIDDEN_BEHAVIOR_INVISIBLE and Ti.UI.HIDDEN_BEHAVIOR_INVISIBLE Updated example:
       var win = Titanium.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var v1 = Ti.UI.createView({
           left: 0,
           width: "50%",
           height: Ti.UI.FILL,
           layout: "vertical"
       })
       
       var v2 = Ti.UI.createView({
           right: 0,
           width: "50%",
           height: Ti.UI.FILL,
           layout: "vertical"
       });
       
       for (var i = 0; i < 7; ++i) {
           var v = Ti.UI.createView({
               width: 50,
               height: 50,
               backgroundColor: "#" + i + "" + i + "" + i + "" + i + "" + i + "" + i,
               bottom: 10,
               hiddenBehavior: Ti.UI.HIDDEN_BEHAVIOR_INVISIBLE
           })
           v1.add(v);
           v.addEventListener("click", onClick);
       }
       for (var i = 0; i < 7; ++i) {
           var v = Ti.UI.createView({
               width: 50,
               height: 50,
               backgroundColor: "#" + i + "" + i + "" + i + "" + i + "" + i + "" + i,
               bottom: 10,
               hiddenBehavior: Ti.UI.HIDDEN_BEHAVIOR_GONE
           })
           v2.add(v);
           v.addEventListener("click", onClick);
       }
       
       function onClick(e) {
           e.source.hide();
       }
       
       var btn = Ti.UI.createButton({
           title: "Show all",
           bottom: 0
       })
       
       btn.addEventListener("click", function() {
           for (var i = 0; i < v1.children.length; ++i) {
               v1.children[i].show();
               v2.children[i].show();
           }
       });
       
       win.add(v1);
       win.add(v2);
       win.add(btn);
       win.open();
       
       
  3. Samir Mohammed 2016-11-21

    Verified fixed, hiddenBehavior: Ti.UI.HIDDEN_BEHAVIOR_INVISIBLE was able to hide the objects in the list of boxes without any of the boxes moving up. While Ti.UI.HIDDEN_BEHAVIOR_GONE was able to hide the objects and then the remaining boxes would move up. *Environment *
       Appcelerator Command-Line Interface, version 6.0.0
       Android 7.0 (Google Nexus 6P)
       Operating System Name: Mac OS X El Capitan
       Operating System Version: 10.11.6
       Node.js Version: 4.6.0
       npm: 4.2.8
       Titanium CLI Version: 5.0.10
       Titanium SDK Version: 6.1.0.v20161121091240
       Xcode: 8.0
       4.8.0.201611121409
       
  4. Marian Kucharcik 2017-12-18

    Hi guys, is there parity for this functionality in iOS? Thanks
  5. Michael Gangolf 2017-12-18

    If I remember correctly there was no equivalent on iOS to release hidden space, so you have to use the height:0 workaround

JSON Source