2014년 12월 6일 토요일

Fetch screen background from database

I was trying to create a setting for custom screen background. So, I saved the chosen picture (in a url form I guess) in the DB. In the screen.intialize, the screen background is set to the fetch value from the DB. But the screen background is not appearing. But with the uploaded images (in the AI2 web app), the background words.  Is there a way to use a url stored DB or non-uploaded image as a screen background?

Note: There are also labels, buttons, and other content on the foreground so using a canvas is not an option.



How about:

set Screen1.BackgroundImage   to     MyFavoriteImage.png  ?

You can save the image in the Media (resources)  or download the image from a web page.

How to save an image into the Media is described in the tutorials: http://appinventor.mit.edu/explore/ai2/hellopurr.html

This describes how to use a WebViewer to grab an url :    http://www.appinventor.org/Chapter24 .   You should also be able to grab a specific image from a web page by using the Web component

Is this what you wanted to know Arielle?     or something else?



It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.



Steve, the Media storage (in AI2 web app) for images is pre-defined. I wanted for the user of the app to be able to customize the background of the screen by selecting an image from the gallery via image picker and store it in the DB (I think it is stored in the local url format). Later on, the user may update the background image as he/she wants and this will just update the DB entry.

Taifun, I attached an image. Hope it helps.




use Do it to find out, if the path to the image is correct



Unfortunately, even adding a "file://" before the url string doesn't work to make it the screen's background image.



probably your issue is, you forgot to set screen background color to none?



Thanks a lot Taifun! That worked! I didn't know that the background colour is "above" the background image.


댓글 없음:

댓글 쓰기