# How to get the height of the bottom panel on android (Which is with buttons)?

**URL:** <https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342>\
**Category:** Other\
**Created:** [February 17, 2024, 5:29pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342 "2024-02-17T17:29:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 17, 2024, 5:29pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/1 "2024-02-17T17:29:41Z")

</div>

How to get the height of the bottom panel on android (Which is with buttons)??

---

<div class="post-metadata">

**Author:** ![kakula](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kakula/32/418_2.png) [@kakula](https://forums.solar2d.com/u/kakula)\
**Post date:** [February 17, 2024, 9:38pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/2 "2024-02-17T21:38:40Z")

</div>

I have struggled once with this … below is a working code … I’m sure it can be much better but at least this is working for me. you can copy paste directly to main.lua to see the results and you can try on simulator with different devices or compile and test on different real devices

Please note that i have anchored the top text Y to 0 and the bottom to 1

@XeduR once posted something much better

```auto
topInset, leftInset, bottomInset, rightInset = display.getSafeAreaInsets()

local topArea = display.screenOriginY + topInset

local bottomArea = display.contentHeight - ( topArea + bottomInset )

local topText = display.newText( "Top Text", display.contentCenterX,topArea, native.systemFont, 20 )
topText:setFillColor(1)
topText.anchorY=0

local bottomText = display.newText( "Bottom Text", display.contentCenterX,bottomArea, native.systemFont, 20 )
bottomText:setFillColor(1)
bottomText.anchorY=1

```

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 18, 2024, 1:59pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/3 "2024-02-18T13:59:53Z")

</div>

![image](https://forums.solar2d.com/uploads/default/original/2X/4/480d24695f347bb0a3ff0e8ac4d7122ed86160b5.jpeg)  
 ![image](https://forums.solar2d.com/uploads/default/original/2X/9/9d5c9b97119c5e758d76a032c8d498c96d49778a.jpeg)

It’s not working out very well

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [February 18, 2024, 2:44pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/4 "2024-02-18T14:44:31Z")

</div>

I’ve been using my `screen.lua` module to handle screen dimension related calculations.

> <https://github.com/SpyricGames/Solar2D-Plugins-Public/tree/main/Screen>
>
> //github.com/SpyricGames/Solar2D-Plugins-Public/tree/main/Screen

Also, what’s not working too well about the images above? What should be happening and what is happening instead?

---

<div class="post-metadata">

**Author:** ![kakula](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kakula/32/418_2.png) [@kakula](https://forums.solar2d.com/u/kakula)\
**Post date:** [February 18, 2024, 3:46pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/5 "2024-02-18T15:46:15Z")

</div>

The first image looks Ok, but the second seems to be shifting up

Can you share your code?

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 18, 2024, 4:03pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/6 "2024-02-18T16:03:12Z")

</div>

I can share the position code of the top group:

```auto
cx, cy, dw, dh = display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight
dpxwidth, dpxheight = display.pixelWidth, display.pixelHeight
dactw, dacth = display.actualContentWidth, display.actualContentHeight
dvieww, dviewh = display.viewableContentWidth, display.viewableContentHeight
originX, originY = display.screenOriginX, display.screenOriginY
bottom = dacth + originY

local uppanel = display.newRect(cx, 0, dw, 150)
uppanel.fill = {
    type = "gradient",
    color1 = {pallete.background[1], pallete.background[2], pallete.background[3]},
    color2 = {pallete.background[1], pallete.background[2], pallete.background[3]},
    direction = "left"
}
local y = originY + uppanel.height/2
if env ~= "simulator" then y = y - display.topStatusBarContentHeight end
uppanel.y = y

```

---

<div class="post-metadata">

**Author:** ![kakula](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kakula/32/418_2.png) [@kakula](https://forums.solar2d.com/u/kakula)\
**Post date:** [February 18, 2024, 4:46pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/7 "2024-02-18T16:46:21Z")

</div>

> [@C2G](#):
>
> ```auto
> local uppanel = display.newRect(cx, 0, dw, 150)
> uppanel.fill = {
> type = "gradient",
> color1 = {pallete.background[1], pallete.background[2], pallete.background[3]},
> color2 = {pallete.background[1], pallete.background[2], pallete.background[3]},
> direction = "left"
> }
> local y = originY + uppanel.height/2
> if env ~= "simulator" then y = y - display.topStatusBarContentHeight end
> uppanel.y = y
> 
> ```

I’m not really sure why you are subtracting from the y value if not simulator!!

This code should work for you:

```auto
topInset, leftInset, bottomInset, rightInset = display.getSafeAreaInsets()
cx, cy, dw, dh = display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight

local topArea = display.screenOriginY + topInset

local uppanel = display.newRect(cx, 0, dw, 150)
uppanel.fill = {
    type = "gradient",
    color1 = {1,1,1},
    color2 = {0,0,0},
    direction = "left"
}

uppanel.y = topArea
uppanel.anchorY=0

```

---

<div class="post-metadata">

**Author:** ![colinmorgan](https://forums.solar2d.com/user_avatar/forums.solar2d.com/colinmorgan/32/241_2.png) [@colinmorgan](https://forums.solar2d.com/u/colinmorgan)\
**Post date:** [February 18, 2024, 8:10pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/8 "2024-02-18T20:10:30Z")

</div>

My experience has been that Samsung devices report zero for `display.getSafeAreaInsets()`, so I’ve started adding the following, and it seems to be working out:

```auto
if ( system.getInfo( "targetAppStore" ) == "google" and bottomInset == 0 ) then
    bottomInset = 40
end

```

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 19, 2024, 1:53pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/9 "2024-02-19T13:53:48Z")

</div>

It’s just that in the simulator, if I subtract from y, the uppanel object goes off the screen, but everything works on the phone (It doesn’t work on all phones)

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 19, 2024, 1:56pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/10 "2024-02-19T13:56:33Z")

</div>

I’m sorry! I forgot to say that the phone panels (top and bottom) are not hidden. Well, you could see it in the picture. That’s why the difficulty arises. If you hide these panels, then everything works flawlessly. I just want to find a universal way to find the height of the bottom panel.

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 19, 2024, 5:00pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/11 "2024-02-19T17:00:17Z")

</div>

![image](https://forums.solar2d.com/uploads/default/original/2X/b/bc1a85ee33d240f4a9d3d8c79aedc402524d48e1.jpeg)  
 ![image](https://forums.solar2d.com/uploads/default/original/2X/3/3a8ce2c374868c1ab5d759fb310e675aa4c81971.jpeg)

It’s different on different screens… On some screens, a fairly large part of the screen is cut out.

---

<div class="post-metadata">

**Author:** ![kakula](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kakula/32/418_2.png) [@kakula](https://forums.solar2d.com/u/kakula)\
**Post date:** [February 19, 2024, 8:33pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/12 "2024-02-19T20:33:57Z")

</div>

what are your config.lua settings

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 20, 2024, 6:12pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/13 "2024-02-20T18:12:35Z")

</div>

```auto
application =

{

    --showRuntimeErrors = true,

    content =

    {

        width = 768,

        height = 1024,

        scale = "letterbox",

        fps = 60,

       

        --[[

        imageSuffix =

        {

                ["@2x"] = 2,

                ["@4x"] = 4,

        },

        --]]

    },

}

```

---

<div class="post-metadata">

**Author:** ![kakula](https://forums.solar2d.com/user_avatar/forums.solar2d.com/kakula/32/418_2.png) [@kakula](https://forums.solar2d.com/u/kakula)\
**Post date:** [February 20, 2024, 7:03pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/14 "2024-02-20T19:03:08Z")

</div>

Ok then.

Try to use the code i sent you exactly or XeduR’s but don’t add or remove anything specially subtracting the Y

The code I sent you is working, but the additions you are making are not proper as it seems

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [February 20, 2024, 8:04pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/15 "2024-02-20T20:04:23Z")

</div>

Also, if you want to keep your navbar visible and use my screen module, you can just comment out the `native.setProperty( "androidSystemUiVisibility", "immersiveSticky" )` to prevent it from automagically hiding the navbar when it starts.

---

<div class="post-metadata">

**Author:** ![ernst3](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/e/bc79bd/32.png) [@ernst3](https://forums.solar2d.com/u/ernst3)\
**Post date:** [February 20, 2024, 8:22pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/16 "2024-02-20T20:22:26Z")

</div>

I suspect that this is related to the same problem I reported a long time ago.  
see: [https://forums.solar2d.com/t/incorrect-definition-of-full-screen-size-empty-area-on-the-height-of-the-navigation-bar/355171/2?u=ernst3](https://forums.solar2d.com/t/incorrect-definition-of-full-screen-size-empty-area-on-the-height-of-the-navigation-bar/355171/2)

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 21, 2024, 1:48pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/17 "2024-02-21T13:48:23Z")

</div>

I’ve already looked at your plugin and done so. But look at the screenshots (Posts above).

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 22, 2024, 1:04pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/18 "2024-02-22T13:04:12Z")

</div>

I realized that there is no solution for this in Solar 2D

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [February 23, 2024, 4:07pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/19 "2024-02-23T16:07:00Z")

</div>

I did check the screenshots, but I can’t really make any sense based on two still images like that. In one, the module has removed the navbar as it does by default and in the other the navbar is still there and I don’t know how the module is being used there.

It’s also possible that this is caused by what ernst3 is saying and needs to be fixed in Solar2D core.

---

<div class="post-metadata">

**Author:** ![C2G](https://forums.solar2d.com/user_avatar/forums.solar2d.com/c2g/32/3908_2.png) [@C2G](https://forums.solar2d.com/u/C2G)\
**Post date:** [February 23, 2024, 5:18pm UTC](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342/20 "2024-02-23T17:18:04Z")

</div>

In both screenshots, the navigation bar is not removed (Bottom)

[Next page](https://forums.solar2d.com/t/how-to-get-the-height-of-the-bottom-panel-on-android-which-is-with-buttons/356342.md?page=2)
