German B4I TableCell Text mittig

gerredtor

Active Member
Licensed User
Hallo ich möchte den text(der auf dem bild zu sehen ist)

mittig in dem bild haben

hier mein code:

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: 
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #MinVersion: 7
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private p1_tv1 As TableView
    Private p1_p4 As Panel
End Sub

Private Sub Application_Start (Nav As NavigationController)  
    NavControl = Nav
                                              
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.LoadLayout("page1")
  
    p1_tv1.Initialize("tv1",False)
    p1_tv1.Width = p1_p4.Width
    p1_tv1.Height = p1_p4.Height
    p1_tv1.Color = Colors.Transparent
  
    Page1.RootPanel.AddView(p1_tv1, 0, p1_p4.Top, p1_p4.Width, p1_p4.Height)
  
    Dim ats As AttributedString
    ats.Initialize("asd", Font.CreateNew(10),1)
    ats.Tag = "testsdasd"
    Dim tc As TableCell = p1_tv1.AddSingleLine("test")
    tc.Bitmap = ResizeImage(LoadBitmap(File.DirAssets, "test.png"),p1_tv1.Width,40)
    tc.Text = ats
    tc.DetailText = ats
    tc.InitializeSingleLine("sdasdsadasdasd")
  
    NavControl.ShowPage(Page1)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
  
End Sub

Private Sub Application_Background
  
End Sub

Sub p1_tv1_AccessoryButtonClicked (SectionIndex As Int, Cell As TableCell)
  
End Sub

Sub ResizeImage (Image As Bitmap, Width As Int, Height As Int) As Bitmap
    Dim PhotoCanvas As Canvas
    Dim PhotoPanel As Panel
    Dim PhotoView As ImageView
    Dim NewImage As Bitmap
 
    PhotoPanel.Initialize("")
    PhotoPanel.Width = Width / 2
    PhotoPanel.Height = Height / 2
 
    PhotoView.Initialize("")
    PhotoView.Bitmap = Image
 
    PhotoPanel.AddView(PhotoView,0,0,Width / 2,Height / 2)

    PhotoCanvas.Initialize(PhotoPanel)
    NewImage = PhotoCanvas.CreateBitmap
 
    Return NewImage
End Sub
 

Attachments

  • IMAG0145.jpg
    IMAG0145.jpg
    132.1 KB · Views: 200
Last edited:

JanPRO

Well-Known Member
Licensed User
Longtime User
Ok, zu deinem Problem: Du kannst die CustomView Eigenschaft nutzen und ein Label zum Panel hinzufügen. Ein Label besitzt die TextAlignment Eigenschaft, der du den ALIGNMENT_CENTER Wert zuordnen kannst.

Jan
 

gerredtor

Active Member
Licensed User
Ok danke, was mir jetzt noch eingefallen ist: man sieht ja neben dem bild ein weises feld, wie bekomme ich das transparent(das bild ist transparent)
 
Top