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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Super Contributor
JeffLemon
Posts: 391
Registered: ‎01-13-2011
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
Please use plain text.
Developer
greenback
Posts: 448
Registered: ‎10-17-2010

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. 

:Rockon:

Please use plain text.
Super Contributor
JeffLemon
Posts: 391
Registered: ‎01-13-2011
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
Please use plain text.
Developer
greenback
Posts: 448
Registered: ‎10-17-2010

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"));

 
:Cool2:

Please use plain text.