Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): minWidth/maxWidth and minHeight/maxHeight for Views #13795

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Apr 9, 2023

const win = Titanium.UI.createWindow();
const view = Ti.UI.createView({
	width: Ti.UI.FILL,
	height: 200,
	maxWidth: 600,
	backgroundColor: "red",
	//borderWidth: 2,
	//borderColor: "green"
})

const viewH = Ti.UI.createView({
	height: Ti.UI.FILL,
	maxHeight: 500,
	width: 200,
	backgroundColor: "blue",
})

const viewInner = Ti.UI.createView({width: 10,left: 0,backgroundColor:"green"});
const viewInner2 = Ti.UI.createView({width: 10,right: 0,backgroundColor:"green"});

const viewHInner = Ti.UI.createView({height: 10,top: 0,backgroundColor:"green"});
const viewHInner2 = Ti.UI.createView({height: 10,bottom: 0,backgroundColor:"green"});

// min + max width
const viewM = Ti.UI.createView({height: 100, backgroundColor: "yellow",
	width: Ti.UI.SIZE,
	minWidth: 100,
	maxWidth: 200,
})
const lbl = Ti.UI.createLabel({text: "test",color: "#000"});
viewM.add(lbl);
myTimer = setInterval(function(){
	lbl.text += "#";
	if (lbl.text.length > 25) {
		clearInterval(myTimer);
		console.log("clear interval")
	}
},250);

// min + max height
const viewMH = Ti.UI.createView({width: 100, backgroundColor: "yellow", top: 0,
	height: Ti.UI.SIZE,
	minHeight: 50,
	maxHeight: 100,
})
const lblMH = Ti.UI.createLabel({text: "test",color: "#000"});
viewMH.add(lblMH);
myTimer2 = setInterval(function(){
	lblMH.text += "\n#";
	if (lblMH.text.length > 20) {
		clearInterval(myTimer2);
		console.log("clear interval")
	}
},250);


view.add([viewInner, viewInner2]);
viewH.add([viewHInner, viewHInner2]);
win.add([view, viewH, viewM, viewMH]);
win.open();

maxWidth/maxHeight:

simplescreenrecorder-2023-04-09_17.21.16.mp4

minWidth/minHeight:

Unbenannt.mp4

(views will grow but not extend the max value)

It won't work if the view has a border at the moment. It's commented out at the moment and shows a warning.

@m1ga m1ga changed the title feat(android): maxWidth for Views feat(android): maxWidth/maxHeight for Views Apr 11, 2023
@m1ga m1ga changed the title feat(android): maxWidth/maxHeight for Views feat(android): minWidth/maxWidth and maxHeight for Views May 3, 2024
@m1ga m1ga changed the title feat(android): minWidth/maxWidth and maxHeight for Views feat(android): minWidth/maxWidth and minHeight/maxHeight for Views May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant