Call the getWindowAvoidArea() method of the window to obtain the avoid area, with type set to AvoidAreaType.TYPE_NAVIGATION_INDICATOR.
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
@Entry
@Component
struct GetBottomNavBarHeight {
context = this.getUIContext();
build() {
Column() {
Button('Get the height of the bottom gesture bar')
.onClick(() => {
let type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR;
window.getLastWindow(this.context.getHostContext()).then((data) => {
let avoidArea = data.getWindowAvoidArea(type);
// Get the height of the navigation bar area
let bottomRectHeight = avoidArea.bottomRect.height;
console.info(`window bottomRectHeight is: ${bottomRectHeight}`);
}).catch((err: BusinessError) => {
console.error(`Failed to obtain the window. Cause: ${JSON.stringify(err)}`);
});
})
}
}
}