Android 自动更改标题颜色

问题描述 投票:0回答:1

我是 Android Auto 的新手,正在使用 react-native-carplay 来开发窗格模板。我遇到文本样式问题,并且不知道如何更改标题颜色。有谁知道如何设置 detailText 标题的颜色?

import { PaneTemplate } from "react-native-carplay";

export const paneTemplate = new PaneTemplate({
    pane: {
        items: [
            {
                text: 'Pane',
                detailText: 'Detail Text',
            },
        ],
    },
    title: 'Pane',
    headerAction: { type: 'back' },
});

Android Auto 模块

import { CarPlay } from 'react-native-carplay';
import { tabBarTemplate } from './templates/tab-bar.template';

export function AndroidAutoModule() {
  console.debug('[AndroidAutoModule]')
  CarPlay.emitter.addListener('didConnect', () => {
    CarPlay.setRootTemplate(paneTemplate);
  });
  CarPlay.emitter.addListener('backButtonPressed', () => {
    CarPlay.popTemplate();
  });
}
android react-native android-auto
1个回答
0
投票

尝试在下面编写代码

import { PaneTemplate } from "react-native-carplay";

// Define your styles for title and detailText
const titleStyle = {
  textColor: '#FF0000', // Replace with your desired color
};

export const paneTemplate = new PaneTemplate({
  pane: {
    items: [
      {
        text: 'Pane',
        detailText: 'Detail Text',
      },
    ],
  },
  title: 'Pane',
  headerAction: { type: 'back' },
  style: {
    title: titleStyle, // Apply the title style
  },
});
© www.soinside.com 2019 - 2024. All rights reserved.