# \[SOLVED\] Trying to switch between Fill Mode to Keep Aspect ratio

**URL:** <https://forum.playcanvas.com/t/solved-trying-to-switch-between-fill-mode-to-keep-aspect-ratio/26874>\
**Category:** Help & Support\
**Tags:** ui, learning, scripting\
**Created:** [August 3, 2022, 8:13am UTC](https://forum.playcanvas.com/t/solved-trying-to-switch-between-fill-mode-to-keep-aspect-ratio/26874 "2022-08-03T08:13:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PlaycanvasDeveloper](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@PlaycanvasDeveloper](https://forum.playcanvas.com/u/PlaycanvasDeveloper)\
**Post date:** [August 3, 2022, 8:13am UTC](https://forum.playcanvas.com/t/solved-trying-to-switch-between-fill-mode-to-keep-aspect-ratio/26874/1 "2022-08-03T08:13:41Z")

</div>

Hie everyone ,  
Not able to set Fillmode to keep Aspect ratio in runtime

Calling this line in intialize function but nothing seems work still I am having output in fill window

`initialize() { this.app.setCanvasFillMode(pc.FILLMODE_KEEP_ASPECT); }; `

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [August 3, 2022, 12:52pm UTC](https://forum.playcanvas.com/t/solved-trying-to-switch-between-fill-mode-to-keep-aspect-ratio/26874/2 "2022-08-03T12:52:49Z")

</div>

Honestly, changing fill mode at runtime is a mess and you have to workaround it. Here’s a project example: [https://playcanvas.com/project/965801/overview/switch-fill-mode-2](https://playcanvas.com/project/965801/overview/switch-fill-mode-2)

Press 1 and 2 in the launch tab to change between fill window and keep aspect ratio of 16:9

---

<div class="post-metadata">

**Author:** ![PlaycanvasDeveloper](https://forum.playcanvas.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@PlaycanvasDeveloper](https://forum.playcanvas.com/u/PlaycanvasDeveloper)\
**Post date:** [August 3, 2022, 2:36pm UTC](https://forum.playcanvas.com/t/solved-trying-to-switch-between-fill-mode-to-keep-aspect-ratio/26874/3 "2022-08-03T14:36:00Z")

</div>

Yes , its working.  
Thanks.
