Does anyone know how to set backgroundColor of the scrollView? I searched the forums everyone using images, I don’t want to use Image I just want to change background color of scrollView when button is clicked.
Example:
If I click Red button, then myScroller.backgroundColor = { 1,0,0}
If I click Green Button then myScroller.backgroundColor = {0,1,0}
Heya the sollution is simple, place display.newRect behind scrollView and change color of it. Simplest and best soultion in my opinion as you can do many things with it.
Solution is simple and it resolved the problem. But it doesn’t change the scrollView backgroundColor. I am going to keep this unSolved so that in next release of Corona, developers do add function like setBackgroundColor to scrollView.
Thanks Rob, I read the code in file widget_scrollView.la I think it will be possible if under public methods there will be a new function like this
-- Function to set the background pf scrollView function scrollView:setBackgroundColor( newRed, newGreen, newBlue ) -- check if any viewBackground Exist remove it self.\_view.\_background:removeSelf() -- or nil -- Create the view's background newBackground = display.newRect( scrollView, 0, 0, opt.width, opt.height ) newBackground = 0 newBackground = 0 newBackground:setFillColor(newRed,newGreen,newBlue) self.\_view.\_background = newBackground self.\_view.\_background:toBack() -- if it overlays existing content end
I can’t compile this open source and test it, but my mind is saying if the above code runs It might put new rectangle on top of the existing scrollView content. Thant can be solve by using toBack().
The logical thing is change the background instead of being a local variable inside the create function to add it as a child object to the scrollView itself. Then you could just do a setFillColor() on the exposed background.
Heya the sollution is simple, place display.newRect behind scrollView and change color of it. Simplest and best soultion in my opinion as you can do many things with it.
Solution is simple and it resolved the problem. But it doesn’t change the scrollView backgroundColor. I am going to keep this unSolved so that in next release of Corona, developers do add function like setBackgroundColor to scrollView.
Thanks Rob, I read the code in file widget_scrollView.la I think it will be possible if under public methods there will be a new function like this
-- Function to set the background pf scrollView function scrollView:setBackgroundColor( newRed, newGreen, newBlue ) -- check if any viewBackground Exist remove it self.\_view.\_background:removeSelf() -- or nil -- Create the view's background newBackground = display.newRect( scrollView, 0, 0, opt.width, opt.height ) newBackground = 0 newBackground = 0 newBackground:setFillColor(newRed,newGreen,newBlue) self.\_view.\_background = newBackground self.\_view.\_background:toBack() -- if it overlays existing content end
I can’t compile this open source and test it, but my mind is saying if the above code runs It might put new rectangle on top of the existing scrollView content. Thant can be solve by using toBack().
The logical thing is change the background instead of being a local variable inside the create function to add it as a child object to the scrollView itself. Then you could just do a setFillColor() on the exposed background.