EDIT: tôi đã nhầm lẫn trong câu trả lời ban đầu của tôi.
Thật không may kiểu được sử dụng cho hộp thoại là nội bộ và không thể sử dụng theo cách tương tự như một số yếu tố holo dễ thao tác khác. I have created an open source project for dealing with this in very simple situations (Tôi hy vọng sẽ mở rộng nó xuống đường và làm cho nó nhiều hơn .. legit). Dưới đây là một liên kết đến một câu trả lời mới mà địa chỉ này nhiều hơn trong chiều sâu: How can I change the color of AlertDialog title and the color of the line under it
Đối với hậu thế, đây là câu trả lời cũ ngây thơ của tôi:
Nhìn vào answer posted here. Đối với mục tiêu cụ thể của bạn, bạn sẽ muốn ghi đè kiểu dialogTitleDecorLayout
(Tôi nghĩ!) thay vì kiểu listSeparatorTextViewStyle
.
Nếu bạn tò mò nơi thiết lập ban đầu, bạn có thể poke quanh tệp themes.xml trong thư mục sdk android của bạn trên máy tính của bạn và tìm kiếm thuộc tính dialogTitleDecorLayout
. Điều này sẽ dẫn bạn đến tệp bố cục dialog_title_holo
cũng nên có trên máy tính của bạn. Ở đó, bạn sẽ tìm thấy mã sau trong bố cục:
<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>
Mã lưu ý là tham chiếu @android:drawable/divider_strong_holo
. Tệp này cũng tồn tại trên máy tính của bạn và nó phải là một 9patch màu xanh lam. Bạn sẽ cần phải tạo ra một 9patch tương tự của một màu sắc khác nhau. Chúc may mắn! Thậm chí nếu điều này không hoàn toàn thuộc tính right Tôi nghĩ bạn xem những gì bạn có thể cần phải làm ở đây ...
Nguồn
2012-09-05 07:27:18
Giải pháp này có phù hợp với bạn không? – Gopinath
Tôi không biết câu trả lời của bạn có giải quyết được http://stackoverflow.com/questions/14439538/how-can-i-change-the-color-of-alertdialog-title-and-the-color-of-the này không -line-under –
@forsubhi Tôi nghĩ nó giải quyết vấn đề đó, nhưng tôi muốn tự mình thử nghiệm nó trước khi đăng câu trả lời chỉ để chắc chắn 100%. (trừ khi bạn đã thử? Trong trường hợp này tôi sẽ vui lòng đăng câu trả lời của tôi) –