ImageView and Transparent

roarnold

Active Member
Licensed User
Longtime User
Afternoon,

I am trying to add "Home", "Settings" and "About" to the bottom of screens in my app. Each of these are .png files and I utilize Transparent but it doesn't appear to be working.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      StartActivity(disclaim)
      hc.Initialize("hc")
      Activity.LoadLayout("1")
          homeicon.Initialize(File.DirAssets, "homeicon.png")
         settingsicon.Initialize(File.DirAssets, "settingsicon.png")
         abouticon.Initialize(File.DirAssets, "abouticon.png")
        ImageView1.Initialize("")
        ImageView2.Initialize("")
        ImageView3.Initialize("")
        ImageView1.Color = Colors.Transparent
        ImageView2.Color = Colors.Transparent
        ImageView3.Color = Colors.Transparent
        Activity.AddView(ImageView1, 80, 380, 50, 40)
        Activity.AddView(ImageView2, 140, 380, 50, 40)
        Activity.AddView(ImageView3, 200, 380, 50, 40)

        ImageView1.Bitmap = homeicon
        ImageView2.Bitmap = settingsicon
        ImageView3.Bitmap = abouticon
          
   End If

Any ideas?

Thanks,
R

p.s. I was able to make this work in a previous application in 1.9 but not sure why it is not in 2.52.
 

klaus

Expert
Licensed User
Longtime User
You must set the background color of the png images to transparent.
When you set
ImageView1.Color = Colors.Transparent
the system sets the Background property to a ColorDrawable.
When you set
ImageView1.Bitmap = homeicon
the system sets the Background property to a BitmapDrawable replacing the previous Background!

Best regards.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Klaus,

Thanks for the input but I had changed around the code and I come up with nothing showing, or a empty ImageView or the same thing I first got which is the black around the icons.

What am I missing?

Thanks,
R
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Questions for you:

1- What do you have in layout "1"
2- Why are you creating those ImageViews in code and not the designer?
3- Why you have all that code in If FirstTime... that will only execute the very first time the app runs.

also, you should be using DIP when adding views.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Questions for you:

1- What do you have in layout "1"
2- Why are you creating those ImageViews in code and not the designer?
3- Why you have all that code in If FirstTime... that will only execute the very first time the app runs.

also, you should be using DIP when adding views.


1. Nothing is in Layout1.
2. The whole application is build programmatically as opposed to designer, kind of find it easier, to me.
3. In some places I have it in "FirstTime" but probably need to move it.
4. Yes, I should be using DIP like all the rest I have. Oversight.

FirstTime is only once is your point. When another activity starts the calling one goes into pause/resume mode. I see.

Thanks,
R
 
Upvote 0
Top