Android Question How to set a label created in code to centered text alignment?

Discussion in 'Android Questions' started by Troberg, Mar 27, 2015.

  1. Troberg

    Troberg Well-Known Member Licensed User

    I create a label in code, and add it using AddView. Most settings I can set through code, but I can't find how to set the text to centered alignment.

    Is it possible?

    Code:
    Dim lblName As Label
    lblName.Initialize(
    "lblName")
    lblName.Text = Main.Glob.DisplayName
    lblName.TextSize = 
    24
    HostPanel.AddView(lblName, 
    0%x30%y100%x40%y)
     
  2. fixit30

    fixit30 Active Member Licensed User

    You could try:

    Code:
    lblName.Gravity = Gravity.CENTER_HORIZONTAL
     
    Gnappos and Troberg like this.
  3. Troberg

    Troberg Well-Known Member Licensed User

    Thanks!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice