Android Question PNG not transparent

Discussion in 'Android Questions' started by kepler, May 5, 2015.

  1. kepler

    kepler Active Member Licensed User

    Good afternoon,

    I'm really confused with a small detail.

    I've created a panel with a color. Inside of it, I've placed an Image View, with Color set to transparent.
    In this last one, I load a PNG image, a rounded icon, where the out borders are transparent.

    My problem, is that these borders appear white, instead of the color of the panel...

    Ok...what am I doing wrong? Can someone point me out the error?

    Kind regards,

    Kepler
     
  2. klaus

    klaus Expert Licensed User

    It would be earier to help if you posted a small project showing the problem.
     
  3. DonManfred

    DonManfred Expert Licensed User

    ... you ALWAYS does not give enough informations. Upload a small project showing the problem (including the transparent png you are talking about)
     
  4. kepler

    kepler Active Member Licensed User

    I'm sorry - I was out of town, without wifi...

    That's not true Don. But, here's a piece of the code:

    Code:
    Sub Globals
        
    Dim pnl2, pnlMain1 As Panel
        
    Dim Label1 As Label   
        
    Dim ImageView1 As ImageView
        
    Dim label2 As Label
        
    Dim StrUtil2 As StringUtils
    End Sub

        pnl2.Initialize(
    "")
        pnl2.color = 
    Colors.Red
        ImageView1.Initialize(
    "Back")
        ImageView1.Color = 
    Colors.Red
        ImageView1.Bitmap = 
    LoadBitmap(File.DirAssets,"back.png")
        
    Activity.AddView(pnl2,0,0,100%x,52dip)
        
    Activity.AddView(ImageView1,4dip,4dip,44dip,44dip)
    Kind regards,

    Kepler
     
  5. wonder

    wonder Expert Licensed User

    Can you post the image? It could the the PNG file itself.
    If that's the case, I'll be able to fix it in less than one minute. :)
     
  6. kepler

    kepler Active Member Licensed User

    Yep :)

    There it is.

    Kepler
     

    Attached Files:

  7. wonder

    wonder Expert Licensed User

    The image file is fine. I've checked the transparency with Photoshop. o_O
     
  8. klaus

    klaus Expert Licensed User

    As already said !
    Post a small project showing the problem, so we can see what exactly you have done and we can test it !
     
  9. kepler

    kepler Active Member Licensed User

    My god... I've posted the main problem - the project is too big!

    BUT...Wonder had a point. Photoshop is assuming the image to have a transparent ground. Not true.
    I transformed it into a bitmap in coreldraw and exported it as png. That worked...

    I can seem to able to understand why photoshop doesn't do the same...I've been working with this program for ages.

    Well...these are mysterious ways...

    Kind regards,

    Kepler
     
    wonder likes this.
  10. MaFu

    MaFu Well-Known Member Licensed User

    Sounds weird.
    I always create my images with Photoshop, never had a problem with transparency.
    But make sure your image in Photoshop has no background layer.
     
  11. Peter Simpson

    Peter Simpson Expert Licensed User

    Here try this:
    Code:
    'Hmm
        pnl2.Initialize("")
        pnl2.color = 
    Colors.Red
        ImageView1.Initialize(
    "Back")
        ImageView1.Color = 
    Colors.red
        ImageView1.Bitmap = 
    LoadBitmap(File.DirAssets,"back.png")
        
    Activity.AddView(pnl2, 00100%x60dip)
        pnl2.AddView(ImageView1, 
    2dip2dip, -156dip)
     
  12. aeric

    aeric Active Member Licensed User

    Add this line:
    Code:
    ImageView1.Gravity = Gravity.FILL
     
  13. aeric

    aeric Active Member Licensed User

    The reason is the ImageView1 is set to 44dip but the original image is 56x56pixel.
    Code:
    Activity.AddView(ImageView1,4dip,4dip,56dip,56dip)
     
  14. klaus

    klaus Expert Licensed User

    Are you sure ?
    Mostly, the problem is not where YOU think but somewhere else.
    If you had posted a small project showing the problem you would have got a solution much faster, instead of needing the helpers try to guess what you could have done wrong!
     
    DonManfred likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice