# Canvas get width returns "fill container" instead of a number

**URL:** <https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948>\
**Category:** Questions about Thunkable X\
**Tags:** canvas, tcanvas\
**Created:** [September 19, 2019, 8:28pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948 "2019-09-19T20:28:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ann.rootb8m34j](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@ann.rootb8m34j](https://community.thunkable.com/u/ann.rootb8m34j)\
**Post date:** [September 19, 2019, 8:28pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/1 "2019-09-19T20:28:17Z")

</div>

Hello,

I am using the canvas and want to get the width of it to determine where to randomly place a sprite. However, the get width method returns the string “fill container” when I run it on my phone. I would assume it should return the numeric value of the size of the canvas?  
I display the value in my button text for debugging purposes.

Thanks,  
Ann

 ![canvassnip](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/1/d13b5a31408e3043df49e0992025b255cc5313b7.png)

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [September 19, 2019, 9:14pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/2 "2019-09-19T21:14:26Z")

</div>

To solve your problem of the absolute size of the canvas must be set to the size of the Stage.

 ![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/9/c9532f9c4ea5e62bf7491e5c94520ef127b27507.png)

---

<div class="post-metadata">

**Author:** ![minhduct4bjhb](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@minhduct4bjhb](https://community.thunkable.com/u/minhduct4bjhb)\
**Post date:** [May 13, 2021, 4:25pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/3 "2021-05-13T16:25:14Z")

</div>

I did exactly what you mention, but the result is not my expectation  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/2/52a2a1287589622b99d2b34438c28ea682d46b0f.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [May 13, 2021, 4:36pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/4 "2021-05-13T16:36:54Z")

</div>

You are replying on a post written 2 years ago. If you want to get attention, create a new post and explain your problem in a clear way and provide screenshots of design and code so others can respond to it.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 13, 2021, 4:40pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/5 "2021-05-13T16:40:19Z")

</div>

I’ve got some ideas to share but will wait for the new post. 🙂

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:08pm UTC](https://community.thunkable.com/t/canvas-get-width-returns-fill-container-instead-of-a-number/234948/6 "2024-11-08T12:08:57Z")

</div>


