2014년 12월 5일 금요일

image sprite sizing: fill parent

I tried to set an imagesprite to have height set to fill parent and width automatic, but the size seems to be automatic for both height and width.

Here is a summary of the settings:

the screen is set to portrait, not scrollable.
The canvas is set to fill parent for both height and width.
The imagesprite has x and y set to 0, height to fill parent and width to automatic. 

The sprite appears in the correct position, but isn't sized correctly.

I've had issues sizing components and saw that there were hints to enable a timer in screen initialize because a delay may be needed to allow the components to size correctly. I tried adding code to set the sizes again programatically because the properties didn't seem to be working. I set the timer interval to 1 second and catch the timer event. Then I set the imagesprite's height to -2 and width to -1, but it still seems to have no effect. 

Does fill parent work for image sprites?



What you could do, is set the height of the image sprite to be the screen height during initialization. Be aware though, if you want the width to stay in proportion, you have to calculate what it should be, because AI2 does not keep image proportions.



Yes, I understand how I could do that; set height and width to automatic and then do the calculation. But I'm teaching programming with middle school students and would like to use the facilities that are available in app inventor and have an explanation on why this isn't working. Should the fill parent option work or is this a bug? 



My apologies. Do you have a simple .aia that I can look at?
Maybe it is a bug, but i would like to check in the next release, which is all about screen sizes and so on.



Please post it to the forum, then also someone else could have a look at it.



I had a project with the same problem, and at MIT they acknowledged that it is a bug. It will be fixed in a next release. Thanks for posting it.


댓글 없음:

댓글 쓰기