Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:38:41+00:00 2026-05-24T06:38:41+00:00

How can I get the width of a label after set its contents? No

  • 0

How can I get the width of a label after set its contents? No initial width set to it.

I have two labels within a table row like followings:

label 1 (label 2)

Here the width of label 1 is not set initially. with the change of contents label 1‘s width has changes and sometimes it causes overlapping with label 2.

Now my main aim is to set the label 2 left dynamically that it does not ovelapp with label 1. I want to do it like following:

  1. first calculate the width of label 1
  2. then set the left of label 2 = width of label 1 + 10

if there is any other way please help.

HERE SOME CODE

var win = Titanium.UI.createWindow({
    title: 'Cleos',
    backgroundImage: 'tablebg.png',
    navBarHidden: true,
});
var tableview = Titanium.UI.createTableView({
    backgroundColor: 'transparent',
    separatorStyle: Ti.UI.iPhone.TableViewSeparatorStyle.NONE,
    style: Titanium.UI.iPhone.TableViewStyle.PLAIN
});
win.add(tableview);
var modelData = new Array;
for (i = 0; i <= daga.length - 1; i++) { // `data` as json, comes from a source
    var row = Titanium.UI.createTableViewRow({
        height: 120.0,
        backgroundColor: 'transparent',
        selectedBackgroundColor: '#380710',
        hasDetail: true
    });
    var imageThumb = Titanium.UI.createImageView({
        image: '...',
        width: 100.0,
        height: 100.0,
        left: 4.0,
        top: 10.0
    });
    row.add(imageThumb);
    var name = Titanium.UI.createLabel({
        text: '...',
        font: {
            fontSize: 16,
            fontWeight: 'bold'
        },
        textAlign: 'left',
        color: '#fff',
        height: 30.0,
        top: 5.0,
        left: 110.0
    });
    row.add(modelname);
    var NumberOfImages = Titanium.UI.createLabel({
        text: '(' + 12 + ')',
        font: {
            fontSize: 16
        },
        width: 'auto',
        color: '#bfbebe',
        textAlign: 'left',
        height: 30.0,
        top: 5.0,
        left: '' // I want to set this `left  = width of label name`
    });
    row.add(NumberOfImages);
    modelData.push(row);
    tableview.setData(modelData);
}
win.open();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:38:42+00:00Added an answer on May 24, 2026 at 6:38 am
    var labelWidth = label.width;
    

    but be careful with ‘auto’ values since they often return 0. the value should be requested after adding the label to the view.

    [update]
    if NumberOfImages.left = name.width+name.left; doesn’t work i would try to calculate the width like

    var pixelPerChar = 8;
    var pseudoWidth = name.text.length/pixelPerChar;
    NumberOfImages.left = pseudoWidth + name.left;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text with font in org.faceless.pdf.PDFFont. How can I get width of it
Here it says that I can get width (of columns I guess) but only
How can I get the width of my LinkButton object ? myLinkButton = new
I have some working code that I altered but I can't seem to get
I have created two view controllers in XCode along with a UIPickerView, a label,
I have article model with public ICollection<Comment> Comments { get; set; } and comment
i trying to get two date from two calender with jquery how can i
I'm using Spring Security 3.0.7 How can I get with java code the access
Can get all triples with value null in specific field? All people with date_of_birth
Can anyone get me with the regular expression to strip multiline comments and single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.