Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6702] TiAPI: Add Padding to Views

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 1.7.5, Release 1.8.0.1, Release 2.1.0, Release 2.0.1
Fix Version/sn/a
ComponentsAndroid
Labelscore, exalture
ReporterMauro Parra-Miranda
AssigneeEric Merriman
Created2011-12-15T14:23:48.000+0000
Updated2018-08-02T17:31:53.000+0000

Description

PROBLEM DESCRIPTION

The customer wants to get the padding functionality provided natively by Android.

DOCS

http://developer.android.com/reference/android/view/View.html To measure its dimensions, a view takes into account its padding. The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific amount of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge. Padding can be set using the setPadding(int, int, int, int) method and queried by calling getPaddingLeft(), getPaddingTop(), getPaddingRight(), getPaddingBottom().

Code

/* Example of padding in labels - 
 * Mauro Parra-Miranda mauropm@gmail.com 
 */


var vLabel = Ti.UI.createView({
	width: 300, 
	height: 35, 
	top: 120
});
var lLabel = Ti.UI.createLabel({
	left: 20, 
	right: 20, 
	text: 'my text', 
	height: 30, 
	backgroundColor:'#fff'
});

vLabel.add(lLabel);

var win1 = Titanium.UI.createWindow({  
    title:'Padding',
    backgroundColor:'#000'
});


win1.add(vLabel);
win1.open();

Comments

  1. Ygor Lemos 2012-08-08

    What about mapping something like: https://gist.github.com/2596057 to the views for iOS? This works great for UILabel but variants can be made for all kinds of views.
  2. Ygor Lemos 2012-09-20

    Check this PR https://github.com/appcelerator/titanium_mobile/pull/2645

JSON Source