- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 AppCompat lib v22.1 为多个 android 版本提供一些 Material 设计。如果我使用新的小部件着色功能,即使使用 AppCompat,它也不会出现在 Kitkat 中。
在布局中:
<Button
android:id="@+id/mybtn"
android:text="Test"
android:theme="@style/MyTheme.BlueButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
在主题 xml 中:
<style name="MyTheme.BlueButton">
<item name="colorButtonNormal">@color/blue</item>
</style>
这是我做错了什么还是 AppCompat 中的错误?
最佳答案
通过使用以下设置,我能够在 Kitkat 和 Lollipop 上获得预期的结果:
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
}
<resources>
<style name="Theme.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
<style name="ThemeOverlay.AppTheme.Blue" parent="ThemeOverlay.AppCompat.Dark">
<!-- ThemeOverlay themes define only some attributes, those which make
backgrounds dark and highlights and texts light for ThemeOverlay.AppCompat.Dark
or the other way around for .Light. The rest is taken from the activity theme.
You only customize what you need - here the button color. -->
<item name="colorButtonNormal">@color/blue_500</item>
</style>
<style name="ThemeOverlay.AppTheme.Yellow" parent="ThemeOverlay.AppCompat.Light">
<!-- This worked correctly even with parent="Theme.AppTheme". -->
<item name="colorButtonNormal">@color/yellow_500</item>
</style>
</resources>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:theme="@style/ThemeOverlay.AppTheme.Blue"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:theme="@style/ThemeOverlay.AppTheme.Yellow"/>
public class MainActivity extends AppCompatActivity { ... }
关于android - appcompat v22.1 小部件着色不显示 pre 5.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30383209/
升级/重构到 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
我是一名优秀的程序员,十分优秀!