- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图通过为白天模式和夜间模式设置自定义主题来更改应用程序组件的一些颜色,如下所示:
在values/styles.xml(白天模式)中:
<resources>
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
...
</resources>
values/styles.xml 中的同一文件(夜间)
我想更改 UI 某些部分的颜色(搜索栏、工具栏、操作栏标题、 float 按钮等),但我不知道每个元素对应哪种颜色,我有点疯狂谷歌搜索对于任何组件的棘手解决方案,我也需要更改颜色。有没有关于在哪里检查所有这些的指南或良好的视觉示例?例如,现在我花了很长时间才弄清楚如何更改弹出菜单背景或操作栏菜单背景,因为菜单文件中没有属性。我是 Android 开发新手,因此非常欢迎任何有关此问题的指导。
最佳答案
您使用了Theme.MaterialComponents.DayNight...
,其中DayNight
更多的是一个自适应动态主题,它会更改为 Material 设计默认颜色。如果您需要对颜色和样式进行更多控制,请执行以下操作:
values/styles.xml
中的 Day
主题应从 Theme.MaterialComponents.Light.DarkActionBar
扩展
values-night/styles.xml
中的 Night
主题应从 Theme.MaterialComponents
扩展,因为它非常适合用于深色模式。
I want to change the color of some parts of the UI (seekbar bar, toolbar, action bar title, floating buttons etc.)
关于这一点,如果您想要应用程序范围内的更改,那么您可以遵循这种样式方法(几乎所有 View 样式都可以通过这种方式完成):
<resources>
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="seekBarStyle">@style/MySeekBarStyle</item>
<item name="toolbarStyle">@style/MyToolBarStyle</item>
<item name="actionBarStyle">@style/MyActionBarStyle</item>
<item name="floatingActionButtonStyle">@MyFloatingActionButtonStyle</item>
<!-- a sample toolbar styling, choose parent with care -->
<!-- your AppTheme inheriting from MaterialComponents but toolbar
<!-- inheriting from platform theme-->
<!-- may case weird visual effects-->
<style name="MyToolBarStyle" parent="Widget.MaterialComponents.Toolbar">
<item name="titleTextColor">@color/lightWhite</item>
<item name="subtitleTextColor">@color/lightWhite</item>
</style>
</resources>
如果您想为每个样式设置例如。 ToolBar
不同的是,您可以在布局文件中使用 style="@style/MyToolBarStyle"
属性来为每个工具栏提供不同的 shape
、颜色
和其他你想要的 Material 效果。
关于颜色:通常,您可以在 styles.xml
中使用这些颜色属性来更改应用的完整外观。
<!-- primary colour of your brand and its variants -->
<item name="colorPrimary">@color/colorPrimary700</item>
<item name="colorPrimaryDark">@color/colorPrimary900</item>
<item name="colorPrimaryVariant">@color/colorPrimary500</item>
<!-- colour which contrasts from your primary colour -->
<item name="colorAccent">@color/colorAccent</item>
<!--secondary colour of your brand and its variants -->
<item name="colorSecondary">@color/colorSecondary700</item>
<item name="colorSecondaryVariant">@color/colorSecondary500</item>
<!--background color for your root layout file -->
<item name="android:colorBackground">@android:color/white</item>
<!--background color of children view -->
<item name="colorSurface">@color/lightWhite</item>
<!--color to show error mostly it will be red or orange
<item name="colorError">@color/colorErrorAlternate</item>
<!-- These are colors which constrasts colors defined for -->
<!-- primary, secondary, bg, surface, error respectively. -->
<!-- For eg: TextViews in Toolbar colored with colorPrimary -->
<!-- will use colorOnPrimary as their text color -->
<item name="colorOnPrimary">@color/lightWhite</item>
<item name="colorOnSecondary">@color/lightDark</item>
<item name="colorOnBackground">@color/lightDark</item>
<item name="colorOnSurface">@color/lightDark</item>
<item name="colorOnError">@color/lightDark</item>
<小时/>
重要链接:
关于java - 切换日夜模式时如何为组件(工具栏、搜索栏、操作栏等)设置自定义颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62096103/
我使用 Runtime.getRuntime().exec 来运行 perl 程序。现在我想在执行过程中显示百分比进度条,然后在perl程序执行完成后,它应该关闭进度条。我该怎么做? Runtime.
我已广泛搜索该网站,但找不到答案。请我是新手,我需要你的帮助。 我想创建一个固定的导航栏,但每次在我的 CSS 样式表中放置一个固定的规则时,导航栏都会消失。这是我的 html 代码:
Here's a nice jsFiddle illustrating the problem 我正在尝试创建一个标题栏元素... 永远只有 1 行高 在右上角有始终存在的控件 在左上角有一个标题,如
int fd = open(JOYSTICK_NAME, O_RDONLY | O_NONBLOCK); O_RDONLY 和 O_NONBLOCK 之间的栏是什么意思?我在 OpenGL/GLUT
我注意到我的网页在页脚之后和页面底部有一个空白/栏: 我试图通过使用 Chrome 中的 inspect 元素来查找此问题的原因,但找不到任何内容。我正在使用 Boostrap,这是我的页脚 HTML
我已经对这个主题进行了一些研究,但我找不到完整的解决方案,因此,我一步一步地尝试和错误,我终于找到了如何实现这些结果:透明或彩色Actionbar 和 Statusbar。请参阅下面的答案。 最佳答案
Highcharts 教程中的经典示例是: $(function () { $('#container').highcharts({ chart: { type: 'bar'
注意 :这与 iOS 13 中使用的新默认模态呈现样式无关。 我有一个奇怪的问题,显示模态 UINavigationController . 考虑一个 UIViewController位于 UINav
我需要帮助了解如何在加载页面时隐藏 iPad 地址栏或顶部的整个地址栏。 我正在开发基于在线客户管理系统的系统,需要隐藏 iPad 地址栏,因为它在查看网站时会占用大量空间。 问候涡流 已经尝试了以下
我在向栏中添加文本时遇到了一些问题。我想在栏上方显示值,但我无法向每个栏添加文本。 现在我的dom结构是: g rect rect rect 我想要什么: g g.bar rect
我有 ListView ,数据将从数据表显示在 ListView 中像这样我已经完成了但是我在数据行 6 有问题 dt = classes.xxxxx.GetData(sql,
我使用 opposite 属性将 xAxis 向右移动。条形图怎么可能也从右侧开始? 谢谢! Highcharts.chart('absoluteInterruptions', { chart:
我得到了这张图片,我想在我的导航 Controller 中使用它: 我是这样设置的(根据 this 问题的建议): UINavigationBar *theBar = self.navigationC
这个问题在这里已经有了答案: How to disable breadcrumbs in Eclipse (11 个答案) 关闭 9 年前。 有谁知道如何删除我在 Eclipse 中用红色圈出的栏?
总而言之,我的应用程序中有一个浏览器,我希望它只启动 5 个网站,仅此而已。有没有办法让我的浏览器通过设置自定义字符串来启动 5 个网站,例如 if {用户键入此字符串} 转到该网站,然后 else
我想在我的应用程序中实现一个进度条。发生的过程是应用程序将一个目录复制到 iOS 文档目录中。通常需要 7-10 秒(iPhone 4 测试)。我对进度条的理解是你在事情发生时更新进度条。但是根据目录
我正在寻找一种创建交互式子弹图的方法,它允许用户单击图中的任意位置并设置一个标记,然后根据该标记所在的位置计算一些简单的值。例如,我希望它看起来类似于: http://www.usrecordings
我目前在一个网站上工作,我有一张人的照片。在图片的右侧,我想要名称和描述。名称应与描述具有不同的背景。我上传了一张它应该是什么样子的图片:http://www.tiikoni.com/tis/view
我将 div 栏设置为不滚动,因此它将始终显示在网站顶部。在这个栏内,我有另一个 div 框,里面有两个按钮,它们向右浮动,所以它们总是在右上角。 问题是我希望按钮居中于页面的右上角而不是右上角。相反
因此,我在我的网站中使用了一个选择栏。我试图在悬停时更改选项的背景颜色。此外,如果有人知道设置垂直 slider 样式的好方法,那就太棒了。 这是我正在尝试做的事情的 fiddle : http://
我是一名优秀的程序员,十分优秀!