gpt4 book ai didi

android - 如何将图标(图像, Logo ..)添加到状态栏

转载 作者:IT老高 更新时间:2023-10-28 23:35:43 26 4
gpt4 key购买 nike

我注意到 StatusBar 组件(React Native)没有任何 Prop 来包含本文档中的任何类型的图标或 Logo : https://facebook.github.io/react-native/docs/statusbar.html#statusbar

我希望在应用程序在后台运行时,在网络栏旁边连续显示一个图标(或者甚至只是一个小的宽度x高度方 block )。我尝试将 View 组件与状态栏结合起来创建一个像这样的红色小矩形:

      <View style={styles.container}>
<StatusBar
backgroundColor="blue"
barStyle="light-content"
/>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
width: 20,
height: 20,
backgroundColor: 'red'
}
})

但是红色方 block 刚刚出现在状态栏下方。有任何想法吗?

编辑:我想要的是即使应用程序在后台也能在状态栏上显示我的应用程序 Logo 。 (提供 VPN 和定位服务的应用程序有时会这样做)。 these are the common icons we see on our status bar but I want to make my own and place it there, say for ex a red circle or any image for that matter..

最佳答案

对于 iOS,无法在状态栏中添加任何自定义图标,Apple 不允许。

对于 Android,您应该使用通知和通知管理器。只需在 java 中编写一个本地模块,在您的应用程序启动时执行此操作。React Native 允许你调用 Java 编写的 Native 模块,看这里 https://facebook.github.io/react-native/docs/native-modules-android.html

您还应该阅读此通知 How to show an icon in the status bar when application is running, including in the background?

关于android - 如何将图标(图像, Logo ..)添加到状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45043222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com