color/colorPrimary
是我想要標題的一些橙色。但我成功地更改了標題文本顏色,這很容易。我想改變標題背景的顏色。這是我到目前爲止有:Android支持警報對話框更改標題背景顏色?
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorPrimary">@color/colorPrimary</item>
<item name="android:windowTitleBackgroundStyle">@style/dialog_title_style</item>
<item name="android:alertDialogStyle">@style/AlertDialog_Sphinx</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
<style name="dialog_title_style" >
<item name="android:background">@color/colorPrimary</item>
<item name="android:padding">100dp</item>
</style>
<style name="AlertDialog_Sphinx">
<item name="android:fullDark">@color/colorPrimary</item>
<item name="android:topDark">@color/colorPrimary</item>
<item name="android:centerDark">@color/colorPrimary</item>
<item name="android:bottomDark">@color/colorPrimary</item>
<item name="android:fullBright">@color/colorPrimary</item>
<item name="android:topBright">@color/colorPrimary</item>
<item name="android:centerBright">@color/colorPrimary</item>
<item name="android:bottomBright">@color/colorPrimary</item>
<item name="android:bottomMedium">@color/colorPrimary</item>
<item name="android:centerMedium">@color/colorPrimary</item>
</style>
public class MyDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder=new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle).setTitle("Naslov")
.setMessage("Poruka......................................................")
.setIcon(android.R.drawable.ic_menu_help)
.setPositiveButton("OK",null);
return builder.create();
}
}
我使用AlertDialog的支持版本(23.1.0)這樣對話框看起來更像是新版Android對話框(材質設計)
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
我想要那個頭是彩色/ colorPrimary(橙色)背景。
肯定的一個選擇,但我雖然headerBackground:#F56321是更簡單的選項。但到目前爲止,造型的所有選擇都沒有幫助。 –