Stylizacja AlertDialog - jak zmienić styl (kolor) tytułu, wiadomości itp
Trochę to łamię głowę. Muszę tylko zmienić styl wszystkichAlertDialog
s w mojej aplikacji na Androida - tło okna dialogowego musi być białe, a tekst musi być czarno-biały. Próbowałem utworzyć wiele stylów, motywów i aplikacji z kodu, manifestu itp., Ale bez powodzenia w odniesieniu do kolorów tekstu wewnątrzAlertDialog
. W tej chwili mam najprostsze kody, ustawione w ten sposób:
Oczywisty:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
styles.xml:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:alertDialogStyle">@style/DialogStyle</item>
</style>
<style name="DialogStyle" parent="@android:style/Theme.Dialog">
<!-- changing these background stuff works fine -->
<item name="android:bottomBright">@android:color/white</item>
<item name="android:bottomDark">@android:color/white</item>
<item name="android:bottomMedium">@drawable/dialog_footer_bg</item>
<item name="android:centerBright">@android:color/white</item>
<item name="android:centerDark">@drawable/dialog_body_bg</item>
<item name="android:centerMedium">@android:color/white</item>
<item name="android:fullBright">@color/orange</item>
<item name="android:fullDark">@color/orange</item>
<item name="android:topBright">@color/green</item>
<item name="android:topDark">@drawable/dialog_header_bg</item>
Wymienione poniżej elementy nie działają (przeczytaj komentarze, które umieściłem nad każdym elementem):
<!-- panelBackground is not getting set to null, there is something squarish around it -->
<item name="android:panelBackground">@null</item>
<!-- Setting this textColor doesn't seem to have any effect at all. Messages, title, button text color, whatever; nothing changes. -->
<item name="android:textColor">#000000</item>
<!-- Also tried with textAppearance, as follows. Didn't work -->
<item name="android:textAppearance">?android:attr/textColorPrimaryInverse</item>
<!-- Also tried changing textAppearancePrimary, to no avail -->
<item name="android:textColorPrimary">#000000</item>
<!-- Also need to change the dialog title text, tried it as follows, dint work: -->
<item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
</style>
DialogWindowTitle jest zdefiniowany w następujący sposób:
<style name="DialogWindowTitle">
<item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item>
</style>
Więc żaden z nich nie działa. Czy ktoś może mi powiedzieć, co mógłbym zrobić źle, i jak mogę:
Zmień kolor tekstu dla wiadomości (tekst treści)Zmień kolor tekstu tytułuUsuń tło paneluUwaga: Muszę obsługiwać API 8 (2.2) w górę. Przeszukałem też większość powiązanych pytań i grup google, ale nie mogę się zorientować, choć mam wrażenie, że mam rację!
Edytuj: dodawanie zrzutu ekranu: