【发布时间】:2016-04-02 05:00:06
【问题描述】:
我正在尝试创建一个自定义多项选择警报对话框,允许用户一键选择/取消选择所有项目。 我使用带有附加复选框的自定义标题来实现这一点。 一切正常,除了我不知道如何使我的自定义标题看起来像默认警报对话框标题(使用相同的样式)。
这是我正在尝试做的(该示例使用Dialogs documentation 中的主题。这只是一个示例,我真正尝试的是应用程序主题)。
我为我使用的自定义标题创建了一个自定义视图,但是我不知道如何获取默认样式标题栏的属性,所以,我得到:
(标题下方没有蓝条,标题颜色错误)
这是我的自定义标题的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/title"
style="?android:attr/textAppearanceLarge"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Dialog title" />
<TextView
android:id="@+id/all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="All" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
对我来说很明显我需要定义标题属性和布局的背景......但是自从几个小时以来我一直在爬网搜索如何获取默认标题视图的属性。
有什么想法吗?
【问题讨论】:
-
颜色很简单。将文本颜色设置为提供的 Holo 蓝色。
-
谢谢,但我希望我的标题具有对话框标题的应用程序默认主题。如果应用程序主题不是 Holo,这不起作用。
标签: android android-layout android-dialog