Android Question How to make text fit to width in a custom dialog.

ProjectGroup19

Active Member
Licensed User
Hello Community,
Please, I want my custom dialog to display text that will fit to width but i'm unsuccessful.

Below is the code i came up with and a picture of what im talking about.


The DESCRIPTION_DIALOG
2021-10-20 (4).png




IMG_20211020_185324_482.jpg

B4X:
Private Sub lblQuoteClick_Click
    CreateDescriptionPanelLayout(300dip,350dip) '300,350
     Wait For(Dialog.ShowCustom(DescriptionPanel, "", "", "CANCEL")) Complete (result As Int)
    If result = xui.DialogResponse_Cancel Then
   
    End If
   
End Sub

IMG_20211020_185324_481.jpg


B4X:
Sub CreateDescriptionPanelLayout( Width As Int, Height As Int)
   
 
    Dim pnl2 As B4XView=Panel2
    Dim text As B4XView=pnl2.GetView(0)
       
    Dialog.Title ="Election Quote"
    DescriptionPanel = xui.CreatePanel("")
    DescriptionPanel.SetLayoutAnimated(0, 0, 0, Width,Height) '400
    DescriptionPanel.LoadLayout("DESCRIPTION_DIALOG")
   
    lblDescription.Text=$""${text.Text}""$
  
    lblOwner.Text=$" ~ ${qname} "$
  
    Dim Height As Int=su.MeasureMultilineTextHeight(lblDescription,lblDescription.Text )+40dip'80
    Dim PnlHeight As Int = Height+ 14dip '14
   
    lblDescription.Height=su.MeasureMultilineTextHeight(lblDescription,lblDescription.Text)
    lblOwner.Top=lblDescription.Height+10dip
    pnlProjectD.Height=Height+lblOwner.Height+10dip
  
    DescriptionPanel.SetLayoutanimated(0,0,0,80%x,PnlHeight+20dip)
 
End Sub
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
Sample b4a and B4J
B4X:
    mTitle.Text = Title
    mMessage.Text = Text
    #If B4A
    Dim SU As StringUtils
    mMessage.Height = SU.MeasureMultilineTextHeight(mMessage, mMessage.Text)
    #Else
    mMessage.As(Label).WrapText = True
    #End If
    Dim rs As ResumableSub = mB4XDialog.ShowCustom(mBase, "OK", "", "")
    Wait For (rs) Complete (Result As Int)
1634776170182.png
1634776187889.png
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
Estimated,

Upload an example of yours and I will help you.

What you see is part of a class that allows changing the theme of the B4Xdialogo and that I am finishing up for a project.
 
Upvote 0
Top