- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已阅读文章How to customize list preference radio button
我使用下面的xml lyaout来自定义我的Dialog,我觉得android Dialog的大部分默认UI都很好,我希望继承att,只改变字体大小。
我发现 CheckedTextView 的默认 att 是 android:checkMark="?android:attr/listChoiceIndicatorSingle".
现在我希望找到这两个<TextView android:id="@+id/dialog_title" ...>
的默认android att和 <ListView android:id="@android:id/list"..>,
你可以告诉我吗?谢谢!
顺便说一句,listPreference 对话框标题的默认样式不是 style="?android:attr/windowTitleStyle"
顺便说一句,如果我使用 style="?android:attr/dialogTitle",我将无法获得相同的标题效果
a.PNG是使用style="?android:attr/dialogTitle"的效果
b.PNG为ListPreference默认对话框标题效果
你可以试试看,使用示例How to customize list preference radio button
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="@drawable/btn_radio_holo_light"
android:gravity="center_vertical"
android:minHeight="@dimen/list_item_minheight"
android:paddingLeft="@dimen/list_item_paddingLeft"
android:paddingRight="@dimen/list_item_paddingLeft" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textColor="@color/title_color"
android:textSize="22sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/divider_color" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
致维克拉姆:
针对 API 9 进行了修改
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:orientation="vertical">
<LinearLayout android:id="@+id/topPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical|start"
android:minHeight="64dip"
android:layout_marginStart="16dip"
android:background="@android:color/white"
android:layout_marginEnd="16dip">
<TextView android:id="@+id/dialog_title"
android:textSize="22sp"
android:textColor="@android:color/black"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="2dip"
android:visibility="visible"
android:background="@android:color/black" />
<!-- If the client uses a customTitle, it will be added here. -->
</LinearLayout>
<LinearLayout android:id="@+id/contentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:minHeight="64dp">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
/>
</LinearLayout>
</LinearLayout>
最佳答案
您可以基于 android 的对话框布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:orientation="vertical">
<LinearLayout android:id="@+id/topPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical|start"
android:minHeight="64dip"
android:layout_marginStart="16dip"
android:layout_marginEnd="16dip">
<TextView android:id="@+id/alertTitle"
android:textSize="22sp"
android:textColor="@android:color/holo_blue_light"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="2dip"
android:visibility="visible"
android:background="@android:color/holo_blue_light" />
<!-- If the client uses a customTitle, it will be added here. -->
</LinearLayout>
<LinearLayout android:id="@+id/contentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:minHeight="64dp">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="?android:attr/selectableItemBackground" />
</LinearLayout>
</LinearLayout>
使用此布局,您可以按照自己的方式自定义对话框:
常规(就像默认一样):
较小的文字大小:
不同的文本颜色和分隔线颜色:
要自定义,更改 TextView
的 text_size
属性,id 为 alertTitle
。您还可以更改 textColor
。
要更改分隔线的颜色/宽度,请查看 TextView
正下方的 View
。
编辑:
我会尝试解决您提到的三点:
#1. android:textColor="@android:color/holo_blue_light" don't work under API 9, how can I set color value for android:textColor? BTW, android:textColor="#ff4d4dff" is wrong.
正确:#ff4d4dff
不是 holo_blue_light
。尝试使用 #ff33b5e5
。
#2. android:listSelector="?android:attr/selectableItemBackground" don't work under API 9, how can I setfor API 9? At present, I use android:background="@android:color/white". BTW, the default background of API 9 is black.
对于 API 9,您可以使用 support-v7 appcompat 库中的 ?selectableItemBackground
。如果您已经在使用此支持库,请将 android:listSelector="?android:attr/selectableItemBackground"
更改为 android:listSelector="?attr/selectableItemBackground"
。要了解我们为什么这样做,请参阅以下答案:Link .
但是如果您不使用这个库,或者不想只为一个可绘制对象包含这个库,您可以基于 API 17 自行构建 selectableItemBackground
。
我已经为此收集了必要的资源。下载此压缩文件夹:Link .在该文件夹中,您将找到 drawable-XXXX
文件夹。将这些内容复制到项目中的相应可绘制文件夹中。如何使用可绘制对象:
android:listSelector="@drawable/item_background_holo_light"
#3. I have to add android:background="@android:color/white" for LinearLayout android:id="@+id/title_template", because the default background of API 9 is black.
是的,这对我来说没问题。
关于android - 如何知道Dialog中title和CheckedTextView默认的android att?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25299140/
使用的浏览器 - Chrome 67.0.3396.99 我创建了一个 DialogsModule它有一个组件 ConfirmDialog.component.ts使用以下模板 confirm-dia
我一直在尝试制作一个简单的程序来使用Electron创建和读取文件。 到目前为止,我已经尝试了很多,并且似乎没有提供与dialog.showOpenDialog一起提供的回调函数。 dialo
我有一个登录对话框,想防止它在按下回车键时自动关闭。 更具体地说,当用户输入凭据并按下回车键时,凭据的响应返回错误,我希望对话框保留(这样我就可以向他们显示一些错误消息,让用户再试一次) . 这就是我
Jquery对话框的含义是什么:它是单独的网页还是网页的一部分? (我不太了解 Jquery)。 谢谢 最佳答案 jQuery 对话框将出现在页面上方,但它实际上是当前页面的一部分。当您加载对话框时,
当用户退出 xe:dialog 时,我需要做一些清理工作。我将代码放在 onUnload 事件中,如下所示: viewScope.remove("vsSomeVariable"); viewScope
我想相对于我的 html 元素之一定位 Dojo 的 Dijit 对话框。是否可以? 如是。如何? 目前它总是在视口(viewport)中间显示对话框。 有人可以帮我解决这个问题吗? 谢谢。 amar
即使属性设置为“openDirectory”,是否也可以在 showOpenDialog 中显示文件?当然,文件不应该是可选的,但可能会显示为灰色。所以用户知道他选择了正确的目录。在 OSX 上一切正
如何使用 android 标准组件 Bottom Sheet 单实现以下设计功能: 出现 Bottom Sheet 对话框片段时的图像: 用户向上滚动以查看内容底部时的图像: 我将使用 ViewPag
我刚开始使用对话框,我非常喜欢在资源文件中定义布局的可能性。但是是否可以设置一个对话框并将其嵌入到另一个对话框中(即没有 float 对话框)? 对于普通窗口,我创建了一个带有一个子窗口的主窗口。然后
我正在尝试更改 dialog 的背景颜色元素的 backdrop使用自定义 CSS 属性,但不需要。这是 Chrome 中的错误还是有原因? document.querySelector('dialo
我有一个 Electron 应用程序。如果我通常使用dialog.showmessageBoxSync,则必须等待用户输入。选项为:关闭,取消或确定。 它工作正常,但是如果我在对话框外部(应用程序内的
我有一个启动确认对话框的 View ,但代码不是等待对话框返回结果,而是直接跳转到 promise 的“then”部分。请参阅下面的代码: ConfirmDialog.ts import { inje
我有一个启动确认对话框的 View ,但代码不是等待对话框返回结果,而是直接跳转到 promise 的“then”部分。请参阅下面的代码: ConfirmDialog.ts import { inje
我正在使用 MonoTouch.Dialog 的 OwnerDrawnElement,但它似乎不允许用户在触摸屏幕时“突出显示”单元格。我查看了示例,但它没有显示突出显示。有什么建议么? 我注意到 T
此选择器在 http://jqueryui.com/demos/dialog/#modal-confirmation 中引用(源代码)。 $( "#dialog:ui-dialog" ).dialog
我有一个奇怪的问题。当 Activity 开始时,我会显示一个对话框,说明某些项目正在加载,如下所示: Dialog dialog; @Override public void onCreate(Bu
jquery-ui 中 .dialog("close") 和 .dialog("destroy") 有什么区别? 我有一个脚本,以前的开发人员使用了 .dialog("destroy") 但现在我必须
我正在使用 Acengage (Ad4Push),我想自定义它的对话框。 Acengage 团队说可以使用自定义主题更改对话框样式,我做到了。我可以更改 textSize、textColor、wind
我有一个标准 View ,顶部有一个导航栏。我还在它自己的源文件中设置了一个 Monotouch.Dialog。我四处寻找解决方案,但似乎找不到关于如何将 MTD 添加到普通 View 的明确答案。
我试图从一个打开的 md-dialog 中打开一个 md-dialog,但问题是第一个 md-dialog 在第二个打开时关闭了 // the controller of the first popU
我是一名优秀的程序员,十分优秀!