Can we find the height of the bar at the bottom of the desktop on some Androids?

StackOverflow https://stackoverflow.com/questions/23085714

  •  04-07-2023
  •  | 
  •  

سؤال

On some of Android devices, there is a bar at the bottom of the desktop that hosts frequently used app icons. What is the common name for this bar?

Here's the problem. We are working on a live wallpaper for Android. The bar covers the essential part of the wallpaper - the bottom part where the ground is on the pictures, see the screen-shots below.

Is there any way to find the height of the bar with Andorid API? That way we could lift up the bottom of the wallpaper avoiding the overlapping by the bar.

enter image description here

enter image description here

هل كانت مفيدة؟

المحلول 2

The common name for that bar is the "dock". And as for your question regarding getting the height of it through the Android API the short answer is no.

Longer answer, each home screen replacement app and possibly each theme used within that app defines their own "dock" if any. You would have to write solutions for multiple possibilities (an example of some popular ones can be found here). You could cut the list down to the default apps used by the most popular ROMs installed on the most popular phones and some may even have APIs or ways to access their settings but you could never cover every case and would have to maintain your code against multiple other apps' updates.

Alternatively you could redesign your wallpapers to assume an average height obscured and not include too much detailed content in that lowest portion of the screen. You could even offer two versions of each wallpaper to the user. One with the buffer for a dock and another without; let them choose which suits their theme best.

Even if you could access the height of a dock across all homescreen apps 100% of the time you'd still need to know whether it is transparent or not, contains app icons and does in fact obscure your wallpaper. Some apps allow the user to toggle the dock between hidden and visible states and thus may be active but not actually covering your wallpaper.

نصائح أخرى

Not sure if this is of any help, but this returns the size of the bottom navigation bar:

int resourceId = context.getResources().getIdentifier("navigation_bar_height",    "dimen", "android");
if (resourceId > 0) {
        return context.getResources().getDimensionPixelSize(resourceId);
}

Maybe there is some other identifier for that quick launchbar.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top