- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 React Navigation 5,我希望我的选项卡栏在特定屏幕上有所不同。我尝试了很多事情但没有成功......我希望第二个屏幕的 tabIcon 仅当事件屏幕是第二个屏幕时才可见,并且当我位于同一屏幕上时也更改选项卡背景颜色。这是我的代码和 2 张照片来展示我想做的事情。
import React from 'react';
import 'react-native-gesture-handler';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import Photo from './Home';
import Folders from './Folders';
import Search from './Search';
import CustomIcon from './components/CustomIcon.js';
import { Dimensions } from "react-native";
const Tab = createMaterialTopTabNavigator();
export default function TabNavigator() {
return (
<Tab.Navigator
initialRouteName = 'Photo'
tabBarOptions= {{
activeTintColor: '#FFCD29',
inactiveTintColor: 'white',
showLabel: true, //icons in label because maxsize of tabBarIcons is 25
showIcon: false,
indicatorStyle:{height: 0},
pressColor: 'transparent',
pressOpacity: 0,
style: {
paddingBottom: 24,
backgroundColor: 'transparent',
// I WANT TAB BACKGROUND COLOR TO BE TRANSPARENT ON PHOTO SCREEN BUT BLACK ON OTHER SCREENS
position: "absolute",
bottom: 0,
width: Dimensions.get('window').width
}
}}
>
<Tab.Screen
name="Search"
component={Search}
options={{
tabBarLabel: ({ color }) => (
<CustomIcon name='SearchScreen' size={45} color={color}/>
),
tabBarAccessibilityLabel: 'SearchScreen',
}}
/>
<Tab.Screen
name="Photo"
component={Photo}
options={{
tabBarLabel: ({ color }) => (
<CustomIcon name='PhotoScreen' size={45} color={color}/>
),
// I DONT WANT TO SEE THIS ICON WHEN ACTIVESCREEN IS PHOTOSCREEN
tabBarAccessibilityLabel: 'Appareil Photo',
}}
/>
<Tab.Screen
name="Dossiers"
component={Folders}
options={{
tabBarLabel: ({ color }) => (
<CustomIcon name='FolderScreen' size={45} color={color}/>
),
tabBarAccessibilityLabel: 'Dossiers',
}}
style = {{backgroundColor: 'black',}}
/>
</Tab.Navigator>
);
}
[SearchScreen]: /image/UGH7L.jpg
[PhotoScreen]: /image/wAfwz.jpg
最佳答案
这是我发现的使中间图标在中间屏幕上消失的解决方案(参见下面的代码)。但有时,当我单击图标而不是使用滑动时,从一种颜色传递到另一种颜色的动画会稍微失败。当我进入 PhotoScreen 时,中间的图标颜色仍然有点可见,就像我没有完全滑动到该屏幕一样。但一旦我点击某个地方,图标就会正确地变为不可见。同样,当我通过单击进入另一个屏幕时,其他图标的 inactiveColor 和 activeColor 之间的更改尚未完成。我针对此错误找到的解决方案是不对其他图标使用 activeTintColor 和 inactiveTintColor ,而是对每个屏幕使用聚焦 Prop 。要根据我所在的屏幕更改选项卡栏的背景颜色,我只是在选项卡栏后面的每个屏幕上添加了不同颜色的 View 。它有效是因为我的标签栏背景颜色是透明的。我还没有直接在react-navigation模块中找到其他解决方案。
<Tab.Screen
name="Photo"
component={Home}
options={({ route }) => ({
tabBarLabel: ({ focused }) => {
let iconColor;
if (route.name === 'Photo') {
iconColor = focused
? 'transparent'
: 'white';
}
return <CustomIcon name='PhotoScreen' size={45} color={iconColor}/>;
},
tabBarAccessibilityLabel: 'Appareil Photo',
})}
/>
关于React-Native 导航 v5 : How to change a tabBarLabel or tabBarIcon and the colorBackground of the tab on a specific screen?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60359124/
在这个 HelloWorld 应用中,我使用了 android:colorBackground 属性,但它没有应用红色背景。 AndroidManifest.xml:
在这个 HelloWorld 应用中,我使用了 android:colorBackground 属性,但它没有应用红色背景。 AndroidManifest.xml:
谁能解释一下,Android 的“android:colorBackground”属性的含义和用法是什么? Android本身如何使用它?我读了doc但这并没有使它更清楚: Color that ma
我正在尝试在此处编辑 ThemeOverlay,其中包含有关弹出窗口和对话框以及类似内容的 dewfaults,但问题是它不接受 colorBackground 属性. 我知道有些人会说我应该使用 a
android:windowBackground和android:colorBackground有什么区别? 例子: @color/black @color/black 哪一个会影响加载新 A
我有一个包含多个皮肤的应用程序。在一个皮肤中,我定义了 android:colorBackground 然后我想在 XML 布局中将此颜色设置为 ViewGroup 背景色。我该怎么做?是否可以?或者
我有一个应用了主题的 BaseActivity,我在其中定义了一个属性 colorBackground 作为我的应用程序的默认背景颜色(比如棕色)。 @color/ap
我正在使用 React Navigation 5,我希望我的选项卡栏在特定屏幕上有所不同。我尝试了很多事情但没有成功......我希望第二个屏幕的 tabIcon 仅当事件屏幕是第二个屏幕时才可见,并
我正在使用 React Navigation 5,我希望我的选项卡栏在特定屏幕上有所不同。我尝试了很多事情但没有成功......我希望第二个屏幕的 tabIcon 仅当事件屏幕是第二个屏幕时才可见,并
是否有最低 android 版本要求才能访问此颜色或其他内容?我需要将对象的背景颜色设置为“默认”背景颜色,并且“?android:colorBackground”在我的 Nexus 5 (Andro
我是一名优秀的程序员,十分优秀!