How does Android Modify the title bar of the built-in dialog box?

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.