Problems using a composite view in Titanium Alloy - titanium

I am trying to implement a simple app in Alloy that has a very basic structure but I cannot get it to layout reliably. I am trying to bottom align a group of navigation buttons with a working area above them which in the following example would be a TableView.
<Alloy>
<Collection src="book">
<Window height="100%" id="main" title="My Library {opts.username}" exitOnClose="true" onOpen="loadExtras">
<TableView id="content" dataCollection="book" top="10px" bottom="100px" onDragEnd="refreshTable">
<TableViewRow title="{title}" color="black" onClick="showBook"/>
</TableView>
<View bottom="0px" height="72px" layout="horizontal" id="actionPanel">
<Button class="footerBtn" onClick="refreshTable">View</Button>
<Button class="footerBtn" onClick="refreshTable">Help</Button>
<Button class="footerBtn" onClick="refreshTable">List</Button>
<Button class="footerBtn add" onClick="addBook"></Button>
</View>
</Window>
The only way I can get this to work is to specify a height for the TableView such as height="80%" and then play with this value until things layout as I would prefer but I do not want to do as I need this to work independently of the devices physical screen size.
How can I implement this kind of layout in Alloy to get a view to pin to the bottom of the screen with a variable working area above it - or, do I have to assume a standard height and work relative to that?

Try pinning the table to the bottom of the parent view and then setting the height to be 80% of the parent view height. Also, use dp values to be screen independent.
<TableView id="content" height="80%" bottom="100dp"
onDragEnd="refreshTable"
dataCollection="book">

Related

How to set a clear button in textfield for android in titanium?

I am trying to set a clear button in text field using clearbuttonmode where it is working fine with Ios Platform and is not showing up in android.
Since clearButtonMode (check your spelling) is only available for iOS as you can see in the documentation I would go the multiplatform way and create a own button and add it next to the TextField. The buttons just sets the TextField value to "" to clear the field. You could even put everything inside a <View> with a white background and a border so it will look like the clear Button is inside the TextField
pseudo code:
<View height="Ti.UI.SIZE" width="300">
<TextField left="0" right="40"/>
<Button width="40" right="0"/>
</View>

Native Script ScrollView and AbsoluteLayout

Im new to NS and I have a project. I want a Button floating inside a ScrollView.
<ScrollView>
<StackLayout orientation="vertical">
<AbsoluteLayout >
<Button top="0" left="0" right="0" text="Test" style="font-size: 10; margin:5; " />
</AbsoluteLayout>
<Label text="Trending Now: " cssClass="trending-label" />
<Repeater items="{{ categories }}">
<Repeater.itemTemplate>
.
.
.
</Repeater.itemTemplate>
</Repeater>
</StackLayout>
</ScrollView>
But its not working. The Button is also scrolling. I want the Button to be floating on ScrollView. Thank you.
The reason why the button is scrolling together with the other items is that everything is situated in a ScrollView. In order to have only the Label and the Repeater scrolling, the Button should be placed outside of it.
Another thing I have noticed is that on the Button, simultaneously are applied left and right alignment, which might cause a problem.
I made a possible implementation of the float button, which you can check here.

titanium alloy raised tab bar with raised center button - dailybooth style

I'm trying to customize my alloy TabGroup to look like the image below (with no luck). no "height" properties on Tab item in the default documentation and with my current version of titanium 3.4.0 can't add View to TabGroup.
anybody know how to create a raised center button using alloy?
that's my index.xml view
<Alloy>
<TabGroup tabsBackgroundColor="white" barColor="#f15b26" activeTabIconTint="black" tintColor="white">
<Require src="home" nr="1" />
<Require src="play" nr="2" />
<Tab icon="/menu/logo.png" height="100">
<Window title="" id="">
<Label></Label>
</Window>
</Tab>
<Require src="chat" nr="3" />
<Require src="config" nr="4" />
</TabGroup>
</Alloy>
you can use an image in the middle of the that exceed the height of the bar.
When we implemented this solution in the past, we did a completely custom tabBar. I dont think you can accomplish what you are trying to do with the base tabBar control

Titanium Alloy LeftNavButton not showing up in simulator

Not sure where I am doing wrong. I tried via code and by xml, but for some reason the left nav button does not show up. I am using the simulator since I don't have an actual device for ios.
The xml view
<!--filename: playType.xml->
<Alloy>
<Window class="container">
<LeftNavButton platform="ios">
<Button title="Back" onClick="closeWindow"/>
</LeftNavButton>
<View class="buttonContainer">
<Button class="menuButton" title="Single Player"/>
<Button class="menuButton" title ="Duel"/>
</View>
</Window>
</Alloy>
The Controller
//playType.js
var args = arguments[0] || {};
var closeWindow = function(){
$.playType.close();
};
The tss style
//playType.tss
".container" : {
backgroundColor:"white",
height:Ti.UI.FILL,
},
".buttonContainer":{
center:{x:"50%",y:"50%"},
height:Ti.UI.SIZE,
layout:"vertical"
}
I using this from the index.js
var playType = Alloy.createController('playType').getView();
playType.open();
The window shows up fine with the two buttons in the center but the back button doesn't appear.
What am I doing wrong. I went through the doc and also tried the code way too. Same result, no back button. :(
You have to create the window using navigation window otherwise navButton wont show up.here goes the code link for you
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.iOS.NavigationWindow
Thanks
Your window must be placed inside a TabGroup which handles all the capabilities of a navigation controller inside each tab.
<Alloy>
<TabGroup>
<Tab id="tab1" title="Tab 1">
<Window id="win1" title="Tab 1">
<LeftNavButton platform="ios">
<Button title="Back" onClick="closeWindow"/>
</LeftNavButton>
...
</Window>
</Tab>
</TabGroup>
</Alloy>
As for the back button, open a child window of the current tab using the tab as the reference to the open method.
tab.open(newWindow);

How to make a button event in pure xaml

I have this code
<Image Name="LightOn_BMP" Source="Res/LightOn.bmp" Canvas.Left="150" Canvas.Top="10" />
<Image Name="LightOff_BMP" Source="Res/LightOFF.bmp" Canvas.Left="150" Canvas.Top="10" />
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOn">
<Image Name="SwitchDown_BMP" Source="Res/SwitchDown.bmp" />
</Button>
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOff">
<Image Name="SwtichUp_BMP" Source="Res/SwitchUp.bmp" />
</Button>
And I want in pure XAML to make the PowerOn event to change so that LightOn.bmp is visible and LightOff.bmp is hidden and hide the Switchdown.bmp picture/button
Then I should be able to figure out how to make the event for the PowerOff
Simply put, you can't. The whole idea behind WPF is that you should separate behavior from display. So, at least without making some crazy black magic, you won't be able to change the state of the Image object (visible to false).