标签: android-theme

Android:如何更改ProgressDialog的文本颜色?

可能重复:
透明,无边框ProgressDialog

Theme.Light在我的应用程序中使用.使用时Progress Dialog,对话框颜色的文字是黑色的,这并不令人鼓舞.

我尝试了这个仅更改对话框的文本颜色,但没有用:

<style name="Theme.MyDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:textColor">#FFFFFF</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我是否必须在任何XML中设置样式(MyDialog)?或者我如何更改对话框的文本颜色?

提前致谢.

android progressdialog android-theme

11
推荐指数
1
解决办法
1万
查看次数

禁用时,从属首选项显示错误的颜色字体

在我的应用程序中,我使用了几个首选项,包括一些使用以下属性与依赖项相关的首选项:android:dependency="pref_key".

基本上,如果未选中该复选框,则会禁用以下所有其他首选项:

没有样式定义的首选项

当我在自定义主题中设置以下3行时,会出现问题:

<style name="AppThemeOrange" parent="@style/AppTheme">
        <item name="android:textColorPrimary">@color/OrangeMain</item>
        <item name="android:textColorSecondary">@color/OrangeDark</item>
        <item name="android:textColorTertiary">@color/OrangeLight</item>
(...)
Run Code Online (Sandbox Code Playgroud)

在这3个属性上定义的颜色也会覆盖禁用的首选项的默认字体颜色:

带样式定义的首选项

首选项仍然被禁用,但显示的字体相反相反...

我搜索了默认的Holo Light样式和主题,但我不知道这个定义的位置以及为什么上面的样式会覆盖这些样式.

有没有人遇到过这个问题?

android android-preferences android-theme android-styles

11
推荐指数
1
解决办法
2403
查看次数

通过样式更改Android Dialog按钮文本大小

我试图通过样式扩大我的所有应用程序对话框按钮上的文本大小.以下代码将更改按钮背景颜色甚至文本大小写,但由于某种原因,textSize项目不符合:

<style name="MyAppTheme" parent="@android:style/Theme.Holo">
    <item name="android:dialogTheme">@style/MyApp.Dialog</item>
    <item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>

<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>

<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
    <item name="android:textSize">50sp</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:background">#800</item>
</style>
Run Code Online (Sandbox Code Playgroud)

带有背景颜色和textAllCaps但没有文字大小的对话框按钮

为什么没有读取textSize?我需要做些什么来扩大它?

android android-layout android-theme android-dialog android-styles

11
推荐指数
2
解决办法
1万
查看次数

在Android中更改背景popupMenu

我试图改变popupmenu的背景,但我的实现不起作用.

这是我的代码:

<style name="MyHoloLight" parent="android:Theme.Holo.Light">
    <item name="android:popupMenuStyle">@style/popupMenuStyle</item>
</style>
<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
    <item name="android:popupBackground">@color/bgPopumMenu</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在AndroidManifest.xml中应用

<application
        android:hardwareAccelerated="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/MyHoloLight">
Run Code Online (Sandbox Code Playgroud)

android android-theme android-styles android-popupwindow

11
推荐指数
3
解决办法
2万
查看次数

应用材质主题时按钮的渲染顺序错误

无论布局结构如何,Button小部件都会绘制在任何其他小部件之上.当应用Material Dark/Light主题时,它在RelativeLayout和FrameLayout中重复.查看下面的屏幕截图,以更好地说明这种奇怪的行为.

检查Nexus 4和Nexus 5.但我怀疑它与设备有关.

它在Android Studio中的外观

它在我的Nexus 4上看起来如何

android android-layout android-theme

11
推荐指数
1
解决办法
1199
查看次数

数据绑定与主题属性

我正在尝试新的Android 数据绑定库,我想使用绑定设置ToolBar的背景颜色.默认情况下,颜色应为colorPrimary(来自主题).

在我使用DataBinding之前,我的工具栏看起来像

 <android.support.v7.widget.Toolbar
        android:id="@+id/mainToolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        />
Run Code Online (Sandbox Code Playgroud)

添加一个绑定后,我想将其背景设置为colorPrimary如果没有绑定颜色 - 我正在使用三元运算符(如指南中所述) - 但它会导致错误,因为主题属性也有一个"?" 操作员在他们的名字前 编译器认为我正在开始新的三元运算.

<data>
    <variable name="toolBarBackgroundColor" type="int"/>
</data>
...
<android.support.v7.widget.Toolbar
        android:id="@+id/mainToolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@{toolBarBackgroundColor!=0? toolBarBackgroundColor: ?attr/colorPrimary }"
        />
Run Code Online (Sandbox Code Playgroud)

那么有没有办法可以在绑定操作中访问主题属性?谢谢!

编辑

我知道我可以通过编程方式获取colorPrimary属性并通过java代码绑定它.但我只是想知道是否有基于Xml的解决方案.

data-binding android android-theme

11
推荐指数
1
解决办法
3273
查看次数

我如何找到什么?android:attr/listChoiceIndicatorSingle指向?

我有

android:button="?android:attr/listChoiceIndicatorSingle"
Run Code Online (Sandbox Code Playgroud)

在CheckBox的布局上.我按F3带我去定义,它只是说

    <!-- Drawable to use for single choice indicators. -->
    <attr name="listChoiceIndicatorSingle" format="reference" />
Run Code Online (Sandbox Code Playgroud)

android-sdk/platforms/android-17/data/res/values/attrs.xml.我搜索了整个文件,这是唯一的情况.

我如何找到它引用的drawable?

android android-theme

10
推荐指数
1
解决办法
4449
查看次数

支持ActionBar不会使用API​​ 21显示正确的颜色

我正在尝试制作一个appcompat主题,但颜色不起作用,图标也不显示......也许我错过了一些东西.这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <color name="background_test">#410000</color>
    <color name="font_general">#ffffff</color>
    <style name="MyTheme"
        parent="@style/Theme.AppCompat">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>

    </style>
    <style name="AudioFileInfoOverlayText">
        <item name="android:paddingLeft">2dp</item>
        <item name="android:paddingBottom">2dp</item>
        <item name="android:textColor">#ffffffff</item>
        <item name="android:textSize">18sp</item>
        <item name="android:shadowColor">#000000</item>
        <item name="android:shadowDx">1</item>
        <item name="android:shadowDy">1</item>
        <item name="android:shadowRadius">1</item>
    </style>

    <!-- general styles for the action bar -->
    <style name="MyActionBar"
        parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="android:icon">@drawable/ic_launcher</item>
        <item name="icon">@drawable/ic_launcher</item>
        <item name="background">@color/background_test</item>
        <item name="android:background">@color/background_test</item>
  </style>

</resources>
Run Code Online (Sandbox Code Playgroud)

我应该添加什么才能使它工作?

编辑:

它也不适用于工具栏......我设置后:

    Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); …
Run Code Online (Sandbox Code Playgroud)

android android-theme

10
推荐指数
2
解决办法
5834
查看次数

检测 Android 设备主题(是深色还是浅色)

您可以为您的应用设置主题,但我想知道是否可以找出设备使用的是哪个主题。目前,我的应用程序使用Theme.AppCompat.Light. 我想避免改变主题。

PS我已经尝试将其设置为Theme.DeviceDefault并使用反射访问其ID,但到目前为止还没有运气。

try {
    setTheme(android.R.style.Theme_DeviceDefault);

    Class<Context> contextClass = Context.class;
    Method getThemeMethod = contextClass.getMethod("getThemeResId");
    getThemeMethod.setAccessible(true);
    Log.d("Test", "" + getThemeMethod.invoke(this)); // Always returns 0

    PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA);
    Log.d("Test", getResources().getResourceEntryName(packageInfo.applicationInfo.theme)); // Returns 'Theme.DeviceDefault'
} catch (Exception e) {
    Log.d("Test", "exception", e);
}
Run Code Online (Sandbox Code Playgroud)

android android-theme

10
推荐指数
1
解决办法
3923
查看次数

Android studio Dolphin Render ui 问题

我将我的 android studio 更新为 Dolphin。我有一些用户界面问题: 1.无限循环尝试解决“?textAppearance”:渲染可能不准确。2.在当前主题中找不到“@android:attr/textAppearance”。

在此输入图像描述

android android-xml android-theme

10
推荐指数
1
解决办法
845
查看次数