How does Android Modify the title bar of the built-in dialog box?
First, we can see from the previous figure that the title Color of the dialog box is blue, and there is a line below that is also blue. In some cases, we want to change the theme style of the program, the color must be modified, but you are too lazy to customize the Dialog. The following method is created:
public static final void dialogTitleLineColor(Dialog dialog, int color) { Context context = dialog.getContext(); /*int divierId = context.getResources().getIdentifier("android:id/titleDivider", null, null); View divider = dialog.findViewById(divierId); divider.setBackgroundColor(color);*/ int divierId = context.getResources().getIdentifier("android:id/alertTitle", null, null); TextView divider = (TextView)dialog.findViewById(divierId); divider.setTextColor(backgroundColor); }
This method can change the title Color of the dialog box and the horizontal line color under the title. I have commented out the changed horizontal line color.
To put it another way, you can use context to obtain the resource id, get the instance of the resource, and modify the attributes of the resource. The modified results are as follows:
Android came out of material design after 5.0, And I used material design to renovate the app I made a long time ago! Download and use it!
Http://shouji.baidu.com/soft/item? Docid = 6936655