編集:元の答えを間違えました。
残念ながら、ダイアログに使用されるスタイルは内部的なものであり、他の簡単に操作できるホロ要素と同じ方法で使用することはできません。私は、非常に単純な状況でこれに対処するためのオープン ソース プロジェクトを作成しました(将来的に拡張して、より合法的なものにしたいと考えています)。これをより詳細に解決する新しい回答へのリンクを次に示します: How can I change the color of AlertDialog title and the color of the line under it
後世のために、これが私の素朴な古い答えです:
ここに投稿された回答を見てください。あなたの特定の目標のために、スタイルではなくdialogTitleDecorLayout
スタイルをオーバーライドしたいと思うでしょう(私は思います!)listSeparatorTextViewStyle
。
これが最初にどこに設定されているか知りたい場合は、コンピューターの android sdk フォルダーにある themes.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>
注目のコードは@android:drawable/divider_strong_holo
参考です。このファイルはコンピュータにも存在し、青色の 9 パッチになっているはずです。異なる色の同様の 9 パッチを作成する必要があります。幸運を!これが適切な属性ではない場合でも、ここで何をする必要があるかがわかると思います...