Re sizing Labels and Panels?

iTzCorky

Member
Licensed User
Longtime User
Hey everyone. I have been stumped on this question. I have an activity which loads a scrollview and 5 labels and a panel. I was wondering how could I re size a panel to the bottom of a label and also move a label to a certain position primarily define its top position?

I know how to set the top position in the designer but the issue is I have a listview on another activity and when a certain listview item is clicked it changes the text so some text is longer than the other. Also I have the labels defined as strings and whenever I attempt to do this it wont let me. If someone could give me an example on how this is done that would be awesome. Thanks!
 

iTzCorky

Member
Licensed User
Longtime User
Here is some code if it helps.

This is activity1(Main):

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Panel1 As Panel
   Dim Panel2 As Panel
   Dim Panel3 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("menu")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Pokemon_Click
   StartActivity(GenerationScreen)
End Sub

This is Activity2 (lViewPoke):
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim Image As String
   Dim Type1 As String
   Dim Type2 As String
   Dim Type1Label As String
   Dim Type2Label As String
   Dim lblText As String
   Dim LBulb As String
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim ListView1 As ListView
   Dim ScrollView1 As ScrollView
   Dim PokeImageInfo As ImageView
   Dim Panel4 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("test")
End Sub

Sub Activity_Resume
 ListView1.AddTwoLinesAndBitmap("#1", "Test", LoadBitmap(File.DirAssets, "1.png"))
   ListView1.AddTwoLinesAndBitmap("#2", "Test", LoadBitmap(File.DirAssets, "2.png"))
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
   If Value = "#1" Then
   StartActivity(BulbAct)
   Image = "1test.png"
   LBulb = "#Test Text"
   Type1 = "Test.jpg"
   Type2 = "Test.jpg"
   Type1Label = "Test"
   Type2Label = "Test"
   lblText = "This is the line that I am having trouble with sizing."
   End If
End Sub

Activity3 (BulbAct):

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim ScrollView1 As ScrollView
   Dim Panel5 As Panel
   Dim Panel4 As Panel
   Dim lblText As Label
   Dim PokeImageInfo As ImageView
   Dim Type1 As ImageView
   Dim Type2 As ImageView
   Dim Type1Label As Label
   Dim Type2Label As Label
   Dim lblText As Label
   Dim LBulb As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("SV")
   PokeImageInfo.Initialize("")
   ScrollView1.Panel.LoadLayout("BulbLayout")
   ScrollView1.Panel.Height = Panel5.Top + Panel5.Height + 10dip
End Sub

Sub Activity_Resume
   PokeImageInfo.Bitmap = LoadBitmap(File.DirAssets, lViewPoke.Image)
   Type1.Bitmap = LoadBitmap(File.DirAssets, lViewPoke.Type1)
   Type2.Bitmap = LoadBitmap(File.DirAssets, lViewPoke.Type2)
   Type1Label.Text = (lViewPoke.Type1Label)
   Type2Label.Text = (lViewPoke.Type2Label)
   lblText.Text = (lViewPoke.lblText)
   LBulb.Text = (lViewPoke.LBulb)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Hope this helps in solving my issue.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Could you explain more in detail what you want to do I'm not sure that I understand it.
Do you have multiline texts in the Labels and want to adjust the heights and positions according to these text chanages?
In this case your test program should have different text lengths.
The adjustment should be in the BulsAct activity and not in the IViewPoke activity.
It would be much easier to help you if you posted your project as a zip file.
How many pseudos do you have on this forum ? This one is the third one.

Best regards.
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User

Hey klaus I will send you my project file because I want to keep secure. But yes this is my third one. We had some issues at the support department but we got them resolved . I will send you what the issues are in a message.
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User
Ok I decided instead of going through all that work I will just post the project. Ok so the listview for some reason keeps repeating itself. I only have 3 of the listview items done, when you click the first listview item that is the look I am trying to maintain just need for the scrollview/panel to resize to the very bottom label and also have all the episodes including the title appearances to move up or down depending on how big the text is above it. EDIT: I cannot upload it, it is to big.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm sorry but it is difficult (at least for me) to delve into large projects.

The question you've asked is:
I was wondering how could I re size a panel to the bottom of a label and also move a label to a certain position primarily define its top position?
I'm not sure that I really understand it. You should only post the code related to the question and also make it more clear what exactly you are trying to achieve.
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User

Ok where the lbltext is that text changes with each listview item that is clicked, it could be longer or it could be shorter. If its to short there is a big white space above the appearance label, I just need to have everything below lbltext to move up and for the panel to resize for the scrollview.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…