什么主题的属性,我需要重写,以改变我的对话框蓝色高亮颜色? [英] What theme attributes do I need to override to change the blue highlight color of my dialogs?

查看:185
本文介绍了什么主题的属性,我需要重写,以改变我的对话框蓝色高亮颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为greenhighlight&mdash主题;使用 Android的动作栏样式生成器生成这个主题,并从默认ActionBarSherlock主题继承。主题什么都不做,除了在动作条的底部,从蓝色变为高亮的绿色。

I have a theme called "greenhighlight" — this theme was generated using the Android Action Bar Style Generator, and inherits from the default ActionBarSherlock theme. The theme does nothing except change the highlight at the bottom of the ActionBar from blue to green.

要主题我所有的活动,我只是做:

To theme all my activities, I just do:

<application android:theme="@style/Theme.greenhighlight"...

本作品pretty的很好的活动(注意在动作条的底部的绿色亮点):

This works pretty well for activities (note the green highlight on the bottom of the ActionBar):

不过,我有困难,我的主题化的对话框,以配合我的活动:

However, I'm having difficulty theming my dialogs to match my activities:

我的greenhighlight_Dialog的主题被定义为:

My "greenhighlight_Dialog" theme is defined as:

<style name="greenhighlight_Dialog" parent="@style/Theme.Sherlock.Dialog">
    <item name="android:progressBarStyleHorizontal">
        @style/greenhighlight_ProgressBar
    </item>
</style>

我是从默认的夏洛特对话的主题继承,并覆盖了使用进度条风格进度条由我生成的greenhighlight的主题和mdash定义;你可以看到进度条是绿色的上面的截图中正确的阴影。

I'm inheriting from the default Sherlock dialog theme, and overriding the progress bar using the progress bar style as defined by my generated "greenhighlight" theme — you can see that the progress bar is the correct shade of green in the screenshot above.

要使用的主题,我正在下面code:

To use the theme, I'm running the following code:

ContextThemeWrapper ctw = 
    new ContextThemeWrapper(this, R.style.greenhighlight_Dialog);
AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
...
ProgressDialog pd = new ProgressDialog(this, R.style.greenhighlight_Dialog);
...

我的问题是,我不知道什么属性我需要重写。我一直在寻找通过<一个href="https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml">styles.xml和<一href="https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml">themes.xml然而,所建议的样式和主题多科(其中指出,R.style参考, ,是不是有据可查的,不彻底描述的样式)mdash;但也有许多关于Theme.Dialog定义的样式,我不能确定我需要重写来得到我想要的改变哪些。

My problem is that I have no idea what attributes I need to override. I've been looking through styles.xml and themes.xml as recommended by the Styles and Themes doco (which notes that "the R.style reference, however, is not well documented and does not thoroughly describe the styles") — but there are a lot of styles defined on Theme.Dialog and I'm unsure as to which ones I need to override to get the change I want.

什么属性,我需要重写我的对话有绿色的标题文字,对选中列表项下的标题和绿色对号一个绿色的亮点吧?

What attributes to I need to override for my dialogs to have green title text, a green highlight bar underneath the title and green check marks for checked list items?

推荐答案

我去周围挖源,并遇到了 alert_dialog_holo.xml 布局文件。这是分隔的看法:

I went digging around the source and came across the alert_dialog_holo.xml layout file. This is the divider view:

<View android:id="@+id/titleDivider"
    android:layout_width="match_parent"
    android:layout_height="2dip"
    android:visibility="gone"
    android:background="@android:color/holo_blue_light" />

AlertController 类,它的可见性设置为可见如果有一个标题present。由于颜色很难codeD,还有的不会是一个办法style属性覆盖此。

In the AlertController class, it's visibility is set to VISIBLE if there is a title present. Since the color is hardcoded, there's not going to be a way to overwrite this with a style attribute.

这是标题视图:

<com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
    style="?android:attr/windowTitleStyle"
    android:singleLine="true"
    android:ellipsize="end"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

所以,使用 windowTitleStyle 。我花了很多追逐,但我最终发现,使用方式:

So it uses the windowTitleStyle. It took a lot of chasing, but I eventually found the style that uses:

<style name="TextAppearance.Holo.DialogWindowTitle">
    <item name="android:textSize">22sp</item>
    <item name="android:textColor">@android:color/holo_blue_light</item>
</style>

继父母风格回来了,我是能够仅通过样式来改变文字颜色:

Following the parent styles back, I was able to change the text color only via styles:

<style name="AppTheme" parent="@android:style/Theme.Holo">
    <item name="android:alertDialogTheme">@style/AlertDialogStyle</item>
</style>

<style name="AlertDialogStyle" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
    <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
    <item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
</style>

<style name="DialogWindowTitle">
    <item name="android:maxLines">1</item>
    <item name="android:scrollHorizontally">true</item>
    <item name="android:textAppearance">@style/DialogWindowTitleAppearance</item>
</style>

<style name="DialogWindowTitleAppearance" parent="@android:style/TextAppearance.Holo.DialogWindowTitle">
    <item name="android:textColor">#00ff00</item>
</style>

现在的分,你无法通过样式改变它,但因为你知道ID,您可以扩展 AlertDialog 类,并拦截它时,它会创建布局(的onCreate),并改变它的颜色。虽然这是私人 AlertController 类处理,所以我不能确定有多少运气,你就会有。我会看这个越来越回来,如果我拿出任何东西。

Now for the divider, you can't change it via styles, but since you know the id, you can extend the AlertDialog class and intercept it when it creates its layout (onCreate) and change it's color. Though this is handled in the private AlertController class, so I'm unsure how much luck you'll have. I'll look into this more and come back if I come up with anything.

这篇关于什么主题的属性,我需要重写,以改变我的对话框蓝色高亮颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆