So this is my code:
var startWeekWin = Ti.UI.createWindow({
title:'Startup Weekend',
layout: 'vertical',
backgroundColor:'#b6e2e2'
});
// create scroll view here
var sv = Ti.UI.createScrollView({
contentWidth:'auto',
contentHeight: 'auto',
top: 0,
showVerticalScrollIndicator: true
});
startWeekWin.add(sv);
var lblPicture = Ti.UI.createLabel({
top: 0,
width: 'fill',
height: 100,
backgroundImage: 'images/StartUpWeekend.png'
});
var lblTitle = Ti.UI.createLabel({
top: 15,
left: 15,
right: 15,
height: '15%',
font: {
fontSize: 24,
fontWeight: "bold",
fontFamily: "Helvetica"
},
text: "What is it?",
color: '#0a3f56',
backgroundColor: '#b6e2e2'
});
var lblText = Ti.UI.createLabel({
top: 30,
left: 15,
right: 15,
height: 70,
font: {
fontSize: 16,
fontFamily: "Helvetica",
},
text: "Etsy doostang zoodles disqus groupon " +
"greplin oooj voxy " +
"zoodles, weebly ning heekya " +
"handango imeem plugg",
color: '#1d1d1d',
backgroundColor: '#b6e2e2'
});
var lblDate = Ti.UI.createLabel({
top: 30,
width: 'fill',
height: 50,
font: {
fontSize: 24,
fontWeight: "normal",
fontFamily: "Helvetica",
fontStyle: "italic"
},
text: " January 23-25, 2015",
color: '#0a3f56',
backgroundColor: '#b6e2e2'
});
// video trailer goes here
var trailer = Ti.UI.createLabel({
top: 35,
width: 'fill',
height: 50,
text: 'Trailer Goes Here',
color: '#1d1d1d',
backgroundColor: '#b6e2e2'
});
// learn more button
var learnMoreButton = Ti.UI.createButton({
top: 40,
left: 40,
right: 40,
width: 180,
height: 50,
title: 'Learn More',
font: {
fontSize: 18,
fontFamily: "Helvetica",
fontWeight: "normal"
},
color: '#0a3f56',
backgroundColor: 'white'
});
sv.add(lblPicture);
sv.add(lblTitle);
sv.add(lblText);
sv.add(lblDate);
sv.add(trailer);
sv.add(learnMoreButton);
And this is what it displays: http://imgur.com/t4AQTMJ
I don't understand why everything is stacking on top of each other.
Could someone point out what I'm missing?
Thanks.
There is many way to build the UI That you want.
First you given all child element of sv(scroll view) to top. Every child element take top from the SV start position.
If you want to give top to every child element of sv then apply layout vertical property to scroll view.
And second way is give top after the end of first element.
every one is taking top from the scroll view so they all are over riding on every one,
First apply first way and let me know if face any difficulty in this.
Not using layout style will give it a property similar position:absolute of HTML.
Not using layout is at times good as it helps in centering the view.
The Issue is with the top that you have given to every element. As all elements have top that is coming over other elements. If you will update the top your layout will be fixed.
Related
I have a text object in fabric.js that I am creating with:
fbText = new fabric.Textbox('#TEST', {
width: 700,
fill: '#303846',
top: 150,
left: 50,
fontSize: 150,
textAlign: 'left',
fixedWidth: 700,
// fontWeight: 'bold',
editable: false,
originY: 'center',
styles: {
// first word of text i.e Test
0: {
//first letter of first word i.e T
0: { fill: '#21bba6', fontSize: 130}
},
}
})
I would like to make the 1st letter higher than the rest of the word. Any thoughts on how that might be possible?
This is what I want to happen:
This is currently happening:
You can use deltaY negative value. There are more available style properties that can be used, have a look at [http://fabricjs.com/docs/fabric.Textbox.html#_styleProperties][1].
var fbText = new fabric.Textbox('#TEST', {
...,
styles: {
0: {
0: {
fill: '#21bba6',
fontSize: 130,
deltaY: -30
}
},
}
})
Seen Behavior
I have an issue with updating canvas elements inside a group after initialization.
I created a basic app that on initialization creates a group containing several elements: font icon(text object), title, description and rect in order to create a border for the group.
Is there any way to solve this problem that dosen't require me to remove and re add the group back to the canvas?
after reading faricjs documentation canvas.renderAll should be enough what am i missing?
Expected Behavior
The Group object that is rendered to the DOM needs to adjust its width according to the new width of the text object in the DOM.
Essentially re-render this individual group object without causing a full re-render of all the other objects in the canvas.
Issue Reproduction Demo
I was able to reproduce the issue here: http://jsfiddle.net/almogKashany/k6f758nm/
Using setTimeout I update the title of the group but the title of the group does not update (even after calling group.setCoords or canvas.renderAll)
SOLUTION
Thanks to #Durga
http://jsfiddle.net/gyfxckzp/
Call addWithUpdate after changing width of rect or text value, so it will recalculate the group dimension.
DEMO
var canvas = new fabric.StaticCanvas('c', {
renderOnAddRemove: false
});
var leftBoxIconWidth = 70;
var placeholderForIcon = new fabric.Text('ICON', {
fontSize: 20,
fontWeight: 400,
fontFamily: 'Roboto-Medium',
left: 10,
top: 20,
originX: 'left',
lineHeight: '1',
width: 50,
height: 30,
backgroundColor: 'brown'
});
var title = new fabric.Text('', {
fontSize: 20,
fontWeight: 400,
fontFamily: 'Roboto-Medium',
left: leftBoxIconWidth,
top: 5,
originX: 'left',
lineHeight: '1',
});
var description = new fabric.Text('', {
fontSize: 20,
fontWeight: 400,
fontFamily: 'Roboto-Medium',
left: leftBoxIconWidth,
top: 25,
originX: 'left',
lineHeight: '1',
});
title.set({
text: 'init title'
});
description.set({
text: 'init description'
});
var groupRect = new fabric.Rect({
left: 0,
top: 0,
width: Math.max(title.width, description.width) + leftBoxIconWidth, // 70 is placeholder for icon
height: 70,
strokeWidth: 3,
stroke: '#f44336',
fill: '#999',
originX: 'left',
originY: 'top',
rx: 7,
ry: 7,
})
let card = new fabric.Group([groupRect, title, description, placeholderForIcon]);
canvas.add(card);
canvas.requestRenderAll();
setTimeout(function() {
title.set({
text: 'change title after first render and more a lot text text text text'
});
groupRect.set({
width: Math.max(title.width, description.width) + leftBoxIconWidth
})
card.addWithUpdate();
// here missing how to update group/rect inside group width after title changed
// to update canvas well
canvas.requestRenderAll();
}, 2000)
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.4.0/fabric.min.js"></script>
<canvas id="c" width="500" height="500" style="border:1px solid #ccc"></canvas>
I would like to put a white bar which would take all of the width at the bottom of the screen. To do so I thought about using absolute positioning with the inherited flexbox parameters.
With the following code it renders something like this.
Here is my code :
var NavigationBar = React.createClass({
render: function() {
return(
<View style={navigationBarStyles.navigationBar}>
//Icon 1, Icon 2...
</View>
);
}
});
var Main = React.createClass({
render: function() {
return(
<View style={mainStyles.container}>
<NavigationBar />
</View>
);
}
});
var mainStyles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#456783',
}
});
var navigationBarStyles = StyleSheet.create({
navigationBar: {
backgroundColor: '#FFFFFF',
height: 30,
position: 'absolute',
flexDirection: 'row',
bottom: 0,
justifyContent: 'space-between'
},
});
I'm new to styling in CSS and not all the properties are available in React-Native. So any help is appreciated, thanks :)
Ok, solved my problem, if anyone is passing by here is the answer:
Just had to add left: 0, and top: 0, to the styles, and yes, I'm tired.
position: 'absolute',
left: 0,
top: 0,
The first step would be to add
position: 'absolute',
then if you want the element full width, add
left: 0,
right: 0,
then, if you want to put the element in the bottom, add
bottom: 0,
// don't need set top: 0
if you want to position the element at the top, replace bottom: 0 by top: 0
This solution worked for me:
tabBarOptions: {
showIcon: true,
showLabel: false,
style: {
backgroundColor: '#000',
borderTopLeftRadius: 40,
borderTopRightRadius: 40,
position: 'relative',
zIndex: 2,
marginTop: -48
}
}
I've been playing with canvas and the awesome fabric library. I can't get text to display in anything other than the normal weight. i.e.
var text2 = new fabric.Text('tseting', {
fontsize: 50,
fontFamily: 'Arial',
fontStyle = 'bold',
left: 100,
top: 100,
fill:"#FF0000"
});
canvas2.add(text2);
The 'bold' tag doesn't get applied. When I created the font.js file suing cufon, I included the bold and italic fonts. Any ideas gratefully received.
You've used the wrong property, and a typo ( the fontStyle = 'bold',).
Use this instead:
var text2 = new fabric.Text('testing', {
fontSize: 50,
fontFamily: 'Arial',
fontWeight: 'bold',
left: 100,
top: 100,
fill: "#FF0000"
});
canvas2.add(text2);
fontStyle refers to italic / normal.
Try fontWeight: bold or fontWeight: 700?
Developing in Titanium Mobile.
I need to remove a view from a scrollView when a delete button is clicked. I have a custom event firing when my button is clicked, which the scrollView listens for. My question is, how do I reference the view that needs to be deleted? These views are added to the scrollView dynamically, and there is no unique information about the view. I tried passing the view itself when firing the custom event, but this does not work. How do I tell the scrollView which view to delete?
When you have a delete button inside the view - that's a piece of cake :) Just get its' parent and delete it - scrollView.remove(e.source.parent);
Here I created a demo page:
var scrollView = Titanium.UI.createScrollView({
contentWidth: 'auto',
contentHeight: 'auto',
top: 0,
showVerticalScrollIndicator: true,
showHorizontalScrollIndicator: true,
layout: 'vertical'
});
var colors = ['red', 'green', 'blue', 'orange', 'purple', 'yellow'];
for (var i = 0; i < 6; i++) {
var view = Ti.UI.createView({
backgroundColor: colors[i],
borderRadius: 10,
width: 300,
height: 200,
top: 10,
id: i
});
scrollView.add(view);
var deleteButton = Ti.UI.createButton({
borderRadius: 3,
style: Ti.UI.iPhone.SystemButtonStyle.PLAIN,
backgroundGradient: {
type: 'linear',
colors: [ '#c7c7c7', '#686868' ],
startPoint: { x: 0, y: 0 },
endPoint: { x: 0, y: 30 },
backFillStart: false
},
title: 'Delete view ' + i,
font: { fontSize: 12, fontWeight: 'bold' },
color: '#fff',
width: 120,
height: 30
});
view.add(deleteButton);
deleteButton.addEventListener('click', function(e) {
Ti.API.info(e.source.id); // use this ID
scrollView.remove(e.source.parent);
});
}
Ti.UI.currentWindow.add(scrollView);