我想改变AlertDialog(Holo Theme)中出现的蓝色Title和蓝线的颜色,我可以通过查看android styles.xml和themes.xml来改变Title的颜色,但我找不到任何属性或样式我可以使用/更改来改变我的XML的颜色.
以下是我用来更改标题颜色的样式
<style name="myAlertDialog" parent="android:Theme.Holo.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowTitleStyle">@style/myAlertDialogTitleStyle</item>
</style>
<style name="myAlertDialogTitleStyle">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">@style/myAlertDialogTitleStyleTextAppearance</item>
</style>
<style name="myAlertDialogTitleStyleTextAppearance">
<item name="android:textSize">22sp</item>
<item name="android:textColor">#ffff8800</item>
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:我原来的答案是错误的。
不幸的是,用于对话框的样式是内部的,不能像其他一些易于操作的全息元素一样使用。我创建了一个开源项目,用于在非常简单的情况下处理这个问题(我希望将其扩展并使其更加..合法)。这是一个新答案的链接,该答案更深入地解决了这个问题:How can I change the color of AlertDialog title and the color of the line under it
对于后代,这是我天真的旧答案:
看看这里发布的答案。对于您的特定目标,您将希望超越dialogTitleDecorLayout风格(我认为!)而不是listSeparatorTextViewStyle风格。
如果您好奇最初设置的位置,您可以查看计算机上 android sdk 文件夹中的 theme.xml 文件并搜索该dialogTitleDecorLayout属性。这应该会引导您找到一个dialog_title_holo布局文件,该文件也应该位于您的计算机上。您应该在布局中找到以下代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true">
<TextView android:id="@android:id/title" style="?android:attr/windowTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dip"
android:paddingLeft="32dip"
android:paddingRight="32dip"
android:gravity="center_vertical|left" />
<ImageView android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="4dip"
android:scaleType="fitXY"
android:gravity="fill_horizontal"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:src="@android:drawable/divider_strong_holo" />
<FrameLayout
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:foreground="?android:attr/windowContentOverlay">
<FrameLayout android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
注意的代码是@android:drawable/divider_strong_holo参考。该文件也存在于您的计算机上,它应该是蓝色的 9patch。您需要创建一个类似的不同颜色的 9 块。祝你好运!即使这不是完全正确的属性,我想您也知道您可能需要在这里做什么......
| 归档时间: |
|
| 查看次数: |
8920 次 |
| 最近记录: |