Label sizing & Image View animations

rbabu

Member
Licensed User
Longtime User
Hi

Just started out with a simple app to try some features of B4A.
Am still finding my feet.. with this.

I have run into some basic problems.

What I am trying to achieve is:

1. Have a circle expanding from the centre (animation)
2. To be able to resize to all devices centred on the screen
3. Have a label displayed that is big enough on the device,center aligned and mutli-line flowing

Is this possible..

I am getting the following problems.

ImageView has a white background -Label does not show fully and text does not centre align (paragraph alignment)

Code is given below... please let me know what I am doing wrong or what needs to be changed.

Regards
Ramesh

Designer setting for image view attached
================================
'Activity module
Sub Process_Globals
Dim SP As MediaPlayer
Dim LoadId1, PlayId1 As Int

End Sub

Sub Globals
Dim ImageView1 As ImageView
Dim a5 As Animation
Dim AdView1 As AdView

Dim Label1 As Label
Dim Label2 As Label
Dim ScrollView1 As ScrollView
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("1")
AdView1.Initialize("Ad", "xxxx") 'publisher id that you received from AdMob.
'AdView1.SetTestDevice(Array As String("xxx"))

Dim Back1 As Bitmap
Dim pearl As Bitmap


Back1.Initialize(File.DirAssets, "back1.png")
pearl.Initialize(File.DirAssets, "xxxl1.png")
Activity.SetBackgroundImage(Back1)

Activity.AddView(AdView1, 0dip, 0dip, 320dip, 50dip)
AdView1.LoadAd


AdView1.BringToFront

If FirstTime Then
SP.Initialize2("sp")
SP.Load(File.DirAssets, "music_1.mp3")
SP.Play
SP.Looping = True
End If

Activity.LoadLayout("1")

a5.InitializeScaleCenter("", 0.5, 0.5, 1, 1, ImageView1)
'ImageView1.SetBackgroundImage(pearl)
ImageView1.Bitmap = pearl
Label1.Text= "Love"
Label1.TextSize = 28.0
Label2.Text ="Many Many Happy Returns of the Day"
Label2.TextSize = 28.0

Dim animations() As Animation
animations = Array As Animation(a5)
For i = 0 To animations.Length - 1
animations(i).Duration = 10000
animations(i).RepeatCount = 1
Next
End Sub

Sub Ad_FailedToReceiveAd (ErrorCode As String)
Log("failed: " & ErrorCode)
Msgbox("Failed","")

End Sub
Sub Ad_ReceiveAd
Log("received")
Msgbox("Ad Received","")
End Sub
Sub Ad_AdScreenDismissed
Log("screen dismissed")
End Sub

Sub ImageView1_Click

a5.Start(ImageView1)


End Sub
 

Attachments

  • imageview.png
    imageview.png
    36.9 KB · Views: 312

rbabu

Member
Licensed User
Longtime User
Attaching project as requested

Hi Erel,

Thanks. I am attaching the project as requested.
I can get animation to work correctly-but the image seems to be having issues with transparencies showing up as white. I can see the image is transparent in gimp, but when exported as PNG or BMP it seems to put in a white background:(

Also...

a)
Set test device comment (commented out in the code gives me compile error). SetTestDevices not defined for AdView. I could not find AdMob command as a valid object to reference either.

<code>
AdMob.SetTestDevices(Array As String("xxxxx"))
AdView1.SetTestDevices(Array As String("xxx"))
</code>

b) with the imageview and label do I need to do any other processing to expand for other device sizes?
 
Upvote 0

rbabu

Member
Licensed User
Longtime User
Label Alignment

Hi Erel
Thanks for your tips
How to make sure the Label has centre alignment for the text it displays?
I get left alignment by default.

Regards
Ramesh Babu
 
Upvote 0

rbabu

Member
Licensed User
Longtime User
Label created from code

Hi Erel

Is there a way to do this in code for a Label I am creating in code?

Regards
Ramesh
 
Upvote 0
Top