Skip to main content
Version: v3

setBrightness

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Set the screen brightness of the current device. If the auto brightness setting is currently turned on, the brightness is automatically adjusted by the light sensor, calling setBrightness will not take effect at this time, you need to use setAutoBrightness to turn off the auto brightness and then set it again. Note: If you exit the current page, you need to consider whether you need to set the brightness back to the original brightness.

Type

function setBrightness(option: Option): Result

Simplified calling method

function setBrightness(brightness: number): Result

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
brightnessnumberY-Screen brightness value, range 0 - 1002.0

Result

TypeDescription
numberIf 0 is returned, success is indicated

Example

import { setBrightness } from '@zos/display'

const result = setBrightness({
brightness: 50,
})

if (result === 0) {
console.log('setBrightness success')
}