我想更改我的应用程序中的所有颜色文本.所以我编写了这段代码,并在清单中设置了我的主题:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但只有TextView文本为白色.我希望Button和EditText也是白色的.
谁能帮我?先感谢您.
android colors android-theme android-edittext android-button
我一直在努力让我PreferenceFragment拥有与我的应用程序其余部分相同的基于材质的主题和样式(通过AppCompat).在PreferenceFragment我使用管理我所有的应用程序设置如下图所示:

正如你可以从上面的截图中看到,我能够自定义PreferenceFragment使用colorAccent,colorPrimary和一些其他属性.我的主题PreferenceFragment如下:
<style
name="settingsTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/blue_grey_500</item>
<item name="colorAccent">@color/blue_grey_500</item>
<item name="android:textColor">@color/black_text_alt</item>
<item name="android:textColorSecondary">@color/black_secondary_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然而,尽管我付出了最大努力,但我无法将主题应用于我内部的各个元素PreferenceFragment,例如ListPreference和EditTextPreference; 所有首选项仍保留标准的AppCompat主题:

我发现一篇2年前的帖子讨论了这个问题,虽然没有真正的解决方案:如何将主题应用于<PreferenceScreen> <PreferenceCategory>元素
我想知道自从AppComat V21发布以来是否有人能够成功地将主题应用于首选项.如果没有,是否有任何可行的解决方法可用于将自定义主题应用于个人偏好?
我在delphi下,我使用android框架创建一个编辑.当我将主题设置为Theme.DeviceDefault.Light.NoActionBar然后我可以在我的EditText中选择一些文本,我有一个弹出窗口"select all/cut/copy/paste/etc",如下图所示.
但是,当我选择Theme.Material.Light.NoActionBar或Theme.Holo.Light.NoActionBar然后我无法选择我的EditText中的任何文本(我没有右或左文本选择句柄),当然我没有任何复制/粘贴弹出窗口
他们是否可以在Theme_Material_Light_NoActionBar上进行此复制/粘贴弹出?
Theme.DeviceDefault.Light.NoActionBar
Theme_Material_Light_NoActionBar
注1:
当我将屏幕移动到水平然后编辑文本占用所有可用空间,然后我可以看到我的左右文本选择句柄,如下图所示,但我认为这是因为主题交换到Theme.DeviceDefault.Light.NoActionBar当我将屏幕移动到水平但我不确定:
注2:
在我的editText上,当我执行setCustomSelectionActionModeCallback(new Callback(){})时,从不调用Callback :(这是不正常的我认为?editText中的哪些内容可以禁止回调?
注2:
我可以在所有主题中选择文本(但我不能将其复制出去),但除了在Theme.DeviceDefault.Light.NoActionBar中,我看不到左右文本选择句柄.
注3:
Theme.DeviceDefault.Light.NoActionBar仅在某些手机上显示左右文本选择句柄,如三星星系.在其他方面它没有用.
注4:
我发现了部分问题的根源!这是因为我通过WindowManager.addView(view,layout_params)创建我的视图,这样startactionmodeforChild返回null,这禁止动作栏和文本选择句柄显示.现在如果我在我的edittext中做了类似的事情:
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
Activity host = (Activity) this.getContext();
return host.getWindow().getDecorView().startActionMode(callback);
}
Run Code Online (Sandbox Code Playgroud)
然后我可以看到左右文本动作句柄(但不是棉花糖,它只在棒棒糖上工作,我不知道为什么).我现在的问题是显示了操作栏,但它显示为空:(内部没有任何内容(但我可以看到剪切/复制/过去控件位于转储视图中的内部).所以现在我不寻找方法通过弹出菜单替换此操作栏(如图片Theme.DeviceDefault.Light.NoActionBar).任何想法?
android textview android-theme android-edittext android-styles
我正在使用继承自己的自定义主题,DarkActionBar我想将自定义下拉菜单设置为白色,就像使用Light Holo主题一样.
我已经能够使用以下方法将背景更改为白色:
<style name="MyTheme" parent="@style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav">
<item name="android:background">@drawable/spinner_background_white</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_whyite</item>
<item name="android:dropDownSelector">@drawable/selectable_background_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但我没有任何关于如何将文字颜色改为黑色的线索.因为在设置白色drawable之后问题是文本不可见因为在白色背景是白色的.
如何从java代码中删除操作栏的阴影?
如果我从样式中删除它工作正常.
<style name="MyTheme" parent="Theme.Sherlock">
....
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
....
</style>
Run Code Online (Sandbox Code Playgroud)
但我需要从java代码中动态删除和添加它.
我正在设计一个Android应用程序,并决定尝试新的Material主题.我在网上找到了新主题的所有可用颜色方案,但我无法找到具有调色板中所有颜色的相应.xml文件.有谁知道我在哪里可以找到这个,以便我可以在我的风格中使用这些颜色?以下是调色板:http://www.google.com/design/spec/style/color.html#color-ui-color-application
我在我的应用程序中使用了AppCompat Light DarkActionBar主题.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
Run Code Online (Sandbox Code Playgroud)

是否可以更改此ActionBar的背景颜色和文本颜色?如果有,怎么样?
我正在尝试为我的 Android 应用程序支持 Android Q Dark 主题,但我无法弄清楚如何根据我当前所在的主题导入不同的资产。
我使用官方的 DayNight 主题来制作深色/浅色版本和可绘制对象,只需指向 XML 就很容易,它会根据启用的内容从 values 或 values-night 中选择正确的值。
我想做一些类似的事情,根据主题它会加载资产“priceTag_light.png”或“priceTag_dark.png”。
val inputStream = if(darkIsEnabled) {
assets.open("priceTag_dark.png")
} else {
assets.open("priceTag_light.png")
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让我得到那个标志?
我想创建卡项xml布局CardView并获取此错误.这里的常见解决方案没有奏效(尝试过所有这些以及其他类似帖子).
这是我的xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="4dp">
</android.support.v7.widget.CardView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是以下相关部分styles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/primary_accent</item>
</style>
<!--Theme for Tool Bar (Action Bar)-->
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是以下相关部分Manifest:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)
这是gradle build脚本的相关部分:
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile …Run Code Online (Sandbox Code Playgroud) android android-layout android-xml android-theme android-studio
我已经看到一些Style属性需要
android前缀,有些不需要它.是什么原因.喜欢
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
为什么我们没有使用android:windowActionBar和android:windowNoTitle
android ×10
android-theme ×10
styles ×2
android-xml ×1
colors ×1
dropshadow ×1
java ×1
kotlin ×1
textview ×1
xml ×1