1

I want to change the font and colour of the title in dialog box, I want change font, size, and colour, what should I do?

here is my code,

ivworknggroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                final Dialog dialog = new Dialog(Ourwork.this);
                dialog.setContentView(R.layout.nggroup);
                dialog.setTitle("N.G.GROUP");

                TextView tvnggroup1 = (TextView) dialog.findViewById(R.id.tvnggroup1);

                TextView tvnggroup2 =(TextView)dialog.findViewById(R.id.tvnggroup2);

                Typeface typeFace1 =  Typeface.createFromAsset(getAssets(),"fonts/antennalight.ttf");
                tvnggroup1.setTypeface(typeFace1);
                Typeface typeFace =  Typeface.createFromAsset(getAssets(),"fonts/antennabold.ttf");
                tvnggroup2.setTypeface(typeFace);

                tvnggroup2.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        // TODO Auto-generated method stub
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.nggroupindia.com/"));
                        startActivity(browserIntent);
                    }
                });
                dialog.show();

            }
        });

can any one help me? thank u.

akky777
  • 423
  • 2
  • 6
  • 23

3 Answers3

1

Well i had a similar situation once, but this is what got it solved for me.

Dialog sortDialog = new Dialog(getApplicationContext());
                sortDialog.setContentView(R.layout.adtype_alertdialog);
                sortDialog.setTitle("N.G.GROUP");
                int dividerId = sortDialog
                        .getContext()
                        .getResources()
                        .getIdentifier("android:id/titleDivider", null,
                                null);
                if (dividerId != 0) {
                    View divider = sortDialog.findViewById(dividerId);
                    divider.setBackgroundColor(getResources().getColor(
                            R.color.yellow));
                }
                TextView tv = (TextView) sortDialog
                        .findViewById(android.R.id.title);
                if (tv != null) {
                    tv.setTextColor(getResources().getColor(R.color.yellow));
                }
                sortDialog.show();

android:id/titleDivider & android.R.id.title in an identifier found in the alert_dialog.xml in your SDK folder

Vaibhav Barad
  • 625
  • 8
  • 17
0

you should use custom view for title of your dialog maybe this link help you how to include custom title view with in AlertDialog in android?

Community
  • 1
  • 1
zohreh
  • 1,055
  • 1
  • 9
  • 26
-1

try this way

private String HALLOWEEN_ORANGE = "#FF7F27";

AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Message").show();

setTitle("Title").
setTitleColor(HALLOWEEN_ORANGE).

setDividerColor(HALLOWEEN_ORANGE).

TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(10);//to change font size
textView.setTextColor(Color.RED); // to change color
//to change font family
Typeface face = Typeface.createFromAsset(getAssets(),"font/fontFileName.ttf");
textView.setTypeface(face);
Dinithe Pieris
  • 1,822
  • 3
  • 32
  • 44
  • I want to change the font and colour of title only not message!!!!! "N.G.GROUP" see it in my post – akky777 Feb 13 '14 at 08:28