Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

how do I get the height of the status bar? #10589

qous started this conversation in General
Jul 22, 2024 · 1 comments · 1 reply
Discussion options

I need to get the height of the status bar from andoird, I use Native Script Vue (js), chat GPT suggests that I get it from a module that does not have this function. Is there any working suggestion on how to get the height of the bar status?

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

Hi! for android you can do:

import { onMounted } from "nativescript-vue";
import { alert, Utils } from "@nativescript/core";

onMounted(() => {
  let resultInPixel = 0;
  const resourceId = Utils.android
    .getResources()
    .getIdentifier("status_bar_height", "dimen", "android");

  if (resourceId > 0) {
    resultInPixel = Utils.android
      .getResources()
      .getDimensionPixelSize(resourceId);
  }

  const resultDIP = Utils.layout.toDeviceIndependentPixels(resultInPixel);
  alert("result is " + resultInPixel + " " + resultDIP);
});

based on: https://stackoverflow.com/a/14213035/6015400

You must be logged in to vote
1 reply
@qous
Comment options

hi, can u help me again ? https://github.com/orgs/NativeScript/discussions/10596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.