Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

ImageView Alpha + Width/Height

Is there a way to change the alpha of my image view? Also is there a way to set it's width and height?

 

Thanks!

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 586
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: ImageView Alpha + Width/Height

There is a way!

To change the alpha us the opacity property which takes values from 0.0 to 1.0

ImageView{
    id: awesomeImage
imageSource: "location/of/image.png"
opacity: 0.5 }

 
To change width/height use preferredWidth and preferredHeight

 

 

ImageView{
    id: awesomeImage
imageSource: "location/of/image.png"
opacity: 0.5
preferredWidth: 500
preferredHeight: 800 }

 

Its that simple. 

Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: ImageView Alpha + Width/Height

Sorry, forgot to mention, I need it in C++, I'm not using QML.

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 586
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: ImageView Alpha + Width/Height

In C++ you would do this:

 

header include

 

#include <bb/cascades/ImageView>

 

the C++ code

 

    ImageView *imageView = new ImageView();
    imageView->preferredHeight(500);
    imageView->preferredWidth(800);
    imageView->opacity(0.5);
    imageView->setImage(Image("location/of/image.png"));