Change background, textcolor of AlertDialog

跟風遠走 提交于 2020-01-06 12:26:11

问题


I try to change background and textcolor of AlertDialog.
But I can change only color of title with android:windowTitleStyle

Activity:
AlertDialog.Builder adb = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));

styles.xml

style name="AlertDialogCustom" parent="Holo.Theme.Sherlock"


How can I do that? Thanks.


回答1:


adb.setMessage(Html.fromHtml("<font color='#FF0000'><b>John:</b></font>"+"How are you?"))

this is for changing text color You can create you own dialog box check this link http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application

http://developer.android.com/guide/topics/ui/dialogs.html




回答2:


Check this

  • Android Custom Dialog Example

  • Custom Dialog Box Popup using Layout in Android




回答3:


try this:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<style name="AlertDialogCustom" parent="@android:style/AlertDialog"> 
    <item name="android:textColor">#00FF00</item> 
    <item name="android:background">#0000FF</item>
    <item name="android:typeface">monospace</item> 
    <item name="android:textSize">10sp</item> 
</style> 
</resources>


来源:https://stackoverflow.com/questions/12938835/change-background-textcolor-of-alertdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!