- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力将我们先前存在的操作栏迁移到 工具栏
,但我遇到了一个小问题。通常我想要一个带有标准白色后退箭头的导航图标。但是,在某些情况下,我想将该箭头更改为灰色。为此,我执行以下操作。
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?actionBarSize"
android:background="?titlebarBackground"
style="?actionBarStyle"
app:navigationIcon="@drawable/action_bar_up_arrow"
app:theme="?toolbarTheme"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
通常我将 ?toolbarTheme
设置为 @style/ThemeOverlay.AppCompat.Dark.ActionBar
。然后,如果我想要一个灰色的向上箭头,我将主题设置为。
<style name="ThemeOverlay.AppCompat.Dark.ActionBar.GrayControls">
<item name="colorControlNormal">@color/gray</item>
</style>
这最初完美无缺,我的向上箭头变为灰色。但是,当我返回时,对于返回堆栈中所有 Activity 的向上箭头,灰色仍然存在。如果我打开一个新的 Activity
,箭头会变成白色,但之前的所有 Activity 的箭头仍然设置为灰色。
我的问题有两个:
最佳答案
Why is this happening?
Drawable 共享一个 ConstantState当从资源创建并且 AppCompat 使用 setColorFilter
时向后移植着色。所以,当你打开一个新的 Activity 时,TintManager在 Drawable 上设置一个 ColorFilter,它更新该 drawable 的所有实例。
What's the best way to fix it?
如果你想在不影响其他实例的情况下使这个可绘制对象可更新,那么你必须使用 drawable.mutate()
这确实应该在图书馆中解决。 编辑 It has been fixed internally .
对于脏修复,在 onResume() 中执行此操作
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
更多信息:
https://code.google.com/p/android/issues/detail?id=78289
http://www.curious-creature.com/2009/05/02/drawable-mutations/
http://developer.android.com/reference/android/graphics/drawable/Drawable.html#mutate()
关于android - AppCompat 工具栏的 colorControlNormal 正在被缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27260859/
升级/重构到 AndroidX 后我收到这个错误androidx.appcompat.appcompat.R 不存在在代码中显示 appcompat 符号无法解析 最佳答案 我遇到了和你一样的错误信息
我在使用 AppCompat 时突然想到,我一直在布局 XML 文件中使用 Button 而不是 android.support.v7.widget.AppCompatButton 之类的东西。我通过
我刚刚升级到 AppCompat v23,发现 setSupportProgressBarIndeterminateVisibility 已弃用。但是,我无法找到替代方案,文档对此似乎非常薄弱。 如果
可以像这样使用 CoordinatorLayout 和自定义 FloatingActionButton: Futuresimple - FloatingActionButton 或 Clans - F
我正忙着尝试实现支持库,以便我可以使用 AppCompatActivty 据我所知,我把所有东西都放在了正确的地方。但我仍然收到错误。 样式.xml
有以下 Theme.AppCompat 类: Theme.AppCompat Theme.AppCompat.Light Theme.AppCompat.Light.DarkActionBar The
我更新了compileSDkversion从 27 日到 28 日。 添加于 gradle.properties文件: android.useAndroidX=true android.enableJ
我正在尝试构建一个 react native 应用程序,但它返回此错误: > Could not resolve all task dependencies for configuration ':a
我正在迁移到 androidX,但我收到: Could not find androidx.appcompat:appcompat:1.0.2. Required by: project :a
我正在尝试升级我的 gradle。当我将 appcompat 从 1.0.2 更新到 1.1.0 时,我的 webview 在某些手机上不再工作。 (API 21 和 22)。 有没有一种聪明的方法可
我是 Android 开发的绝对初学者,并尝试构建测试自动化来测试移动应用程序。经过数周的 IntelliJ 设置后,我仍然面临问题,其中包括以下问题。 因为我使用的是 SDK ver 29,我被告知
我正在使用 v7 appcompat 支持库。操作项在 actionBar 中显示的工作在较新或较旧的设备上都很好。 但是,我没有在 API 7 上得到溢出。例如: appco
最新链接app-compat这是1.1.0 . 将我的应用程序升级到最新版本后 app-compat我的语言设置在 以下的手机上停止工作API 24 (粗略地说,肯定不适用于 API 21 及以下版本
这里的 iOS 开发人员被扔进了 Android 项目的狼群中。我收到一些错误代码,它们都表示类似于 ThemeUtils: View class androidx.appcompat.widget.
这里的 iOS 开发人员被扔进了 Android 项目的狼群中。我收到一些错误代码,它们都表示类似于 ThemeUtils: View class androidx.appcompat.widget.
我最近将我的应用程序升级为 Material 主题。但是,我在 4.2.2 三星平板电脑上遇到崩溃。堆栈跟踪(在下面发布)告诉我我没有使用 Theme.AppCompat 的后代,尽管我相信我是。该应
我正在使用 AppCompat 22.1.1 Base.Widget.AppCompat.Button 和 Widget.AppCompat.Button 有什么区别? 最佳答案 在 AppCompa
我已经在多个地方看到了这个问题。问题似乎与过去的gradle版本3和android studio版本3的更新有关。每当我将依赖项更改为较新的版本时,我都会不断收到错误消息: Could not fin
我已将此资源添加到我的项目中,它向我显示了一个警告。 我该如何解决? The problem still continues (I don't know, if I
我为建议行定义了一个布局,但在将 AppCompat 库更新到 22.1 后,忽略了 styles.xml 中定义的布局。 这是我的 styles.xml 文件(已简化): @style/S
我是一名优秀的程序员,十分优秀!