Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9277] Android: Cannot add label to a button. Works on iOS

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2020-01-09T22:09:00.000+0000
Affected Version/sRelease 2.0.1, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api, parity
ReporterVarun Joshi
AssigneeUnknown
Created2012-05-25T08:05:03.000+0000
Updated2020-01-09T22:09:00.000+0000

Description

Problem

Please run the sample code below: {noformat} //create component instance var self = Ti.UI.createWindow({ backgroundColor : '#ffffff', navBarHidden : true, exitOnClose : true }); self.open(); var button = Ti.UI.createButton({ top: 10, left: 50, width: 200, height: 100, image: 'KS_nav_ui.png' }); var label = Ti.UI.createLabel({ text: 'Hello World' }); button.add(label); self.add(button); {noformat} On Android, the above code does not display the label on the button. It works fine on iOS. The desired effect should be the same as iOS where the button image is shown on the left (as shown in the screenshot) and label on the right.

Attachments

FileDateSize
Screen Shot 2012-05-25 at 8.26.15 AM.png2012-05-25T08:26:50.000+0000502900

Comments

  1. Ivan Skugor 2012-05-29

  2. Josh Roesslein 2012-06-28

    Yes on Android the Button widget is NOT a ViewGroup. What is the use case here of using a Label rather then just setting the "title" of the button? I don't think supporting child views in Buttons will be something we support on Android. Like Blain says there might be a better way to accomplish what you are trying to do.
  3. Ping Wang 2012-07-09

    We can use "\n" to break the line for the "title" of the button on Android and Mobile Web.
  4. jithinpv 2013-02-25

    Issue still present in the following sdk versions - version 3.0.2, version 3.1.0. So the bug can be reproduced in the latest build.
  5. Ygor Lemos 2013-04-22

    This feature is necessary in cases where you want to position text or counters inside a button view. By having this you can make custom buttons. The title parameter on the button view doesn't allow much customization, specially regarding the positioning of the text.

JSON Source