Skip to content

feat(android): padding for Ti.UI.Button #14198

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Apr 3, 2025

Currently Android only:

Adding padding to the Ti.UI.Button

Screenshot_20250403-173638

Button 2 and 4 are default Ti buttons (without and with a custom background color). Currently there was no way to set a custom padding. Even worse: we've set the default padding for a button with background to a very small value for buttons with background color:

12.6.3.GA
Screenshot_20250403-174004
(top: default color, bottom: custom background color).

Fix
This PR will set the default padding for a button with backgroundColor to the native padding again (first image, button 4) and gives the option to define a custom padding (first image, button 1 and 3).

Example

var win = Ti.UI.createWindow({layout:"vertical"});
var btn1 = Ti.UI.createButton({
	title: "just a text in a button",
	padding: {
		left: 50, right: 50, top: 20, bottom: 20
	}
});
var btn2 = Ti.UI.createButton({
	title: "just a text in a button",
});
var btn3 = Ti.UI.createButton({
	title: "just a text in a button",
	backgroundColor:"red",
	padding: {
		left: 50, right: 50, top: 20, bottom: 20
	}
});
var btn4 = Ti.UI.createButton({
	title: "just a text in a button",
	backgroundColor:"red"
});
btn2.addEventListener("click", function() {
	btn2.padding = {left: 50, right: 50, top: 20, bottom: 20};
});
btn4.addEventListener("click", function() {
	btn4.padding = {left: 50, right: 50, top: 20, bottom: 20};
});
win.add([btn1, btn2, btn3, btn4]);
win.open();

You can click Button 2 and 3 to test the property change.

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