3

below is my code work fine only problem is its show so small font size of dialog title how i wil change font size any idea???

Dialog dialog2;
dialog2 = new Dialog(context);
View vLoad = LayoutInflater.from(ActivityHome.this).inflate(R.layout.timer, null);
dialog2.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog2.setContentView(vLoad);
dialog2.setTitle( Html.fromHtml("<font color='#ffffff' > Due Alert</font>"));
dialog2.show();
MilapTank
  • 9,988
  • 7
  • 38
  • 53
user3472001
  • 855
  • 2
  • 7
  • 9
  • Go to this so post [http://stackoverflow.com/questions/820398/android-change-custom-title-view-at-run-time](http://stackoverflow.com/questions/820398/android-change-custom-title-view-at-run-time) – M D Apr 11 '14 at 07:25
  • 1
    dialog2.setTitle( Html.fromHtml("

    Due Alert

    ")); this code work thnx my self
    – user3472001 Apr 11 '14 at 07:26
  • all right and happy coding! – M D Apr 11 '14 at 07:27

3 Answers3

9

Try this:

TextView title =  new TextView(context);
        title.setText("Due Alert");
        title.setGravity(Gravity.CENTER);
        title.setTextSize(30);
        title.setBackgroundColor(Color.GRAY);
        title.setTextColor(Color.WHITE);
    dialog2.setCustomTitle(title);
jyomin
  • 1,957
  • 2
  • 11
  • 27
0

Try This,

dialog2.setTextSize(14);

0

u have another option, design a xml layout for your dialog box how u requird and call it in your activity

example xml:

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="215dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/custom_alert"
android:orientation="vertical" >

<TextView
    android:id="@+id/tv_header"
    android:layout_width="fill_parent"
    android:layout_height="26dp"
    android:gravity="center"
    android:text="@string/oops"
    android:textColor="#3f3f3f"
    android:textSize="15sp"
    android:textStyle="bold"
     />

<TextView
    android:id="@+id/tv_description"
    android:layout_width="fill_parent"
    android:layout_height="58dp"
    android:layout_below="@+id/tv_header"
    android:gravity="center"
    android:textColor="#747474"
    android:textSize="10sp"
    android:typeface="sans" />

<View
    android:id="@+id/separator"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:layout_above="@+id/tv_actionbtn"
    android:layout_centerVertical="true"
    android:background="#b8b8b8" />

<TextView
    android:id="@+id/tv_actionbtn"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:layout_below="@+id/tv_description"
    android:gravity="center"
    android:textColor="#d61820"
    android:textSize="15sp"
    android:typeface="sans" />

custom_alert background layout:

<corners android:color="#FFFFFF" />

<solid android:color="#FFFFFF" />

<stroke
    android:width="3dip"
    android:color="#FFFFFF" />

<corners
    android:radius="20dip"
    android:color="#FFFFFF" />

<padding
    android:bottom="0dip"
    android:left="0dip"
    android:right="0dip"
    android:top="0dip" />

here is the activity code

dialog = new Dialog(Activity.this);
        dialog.setContentView(R.layout.customdialog);

        dialog.getWindow().setBackgroundDrawable(
                new ColorDrawable(android.graphics.Color.TRANSPARENT));
        txtHeader = (TextView) dialog.findViewById(R.id.requiredheader);
        txtDiscription = (TextView) dialog.findViewById(R.id.requireddescription;
        txtHeader.setText(getResources().getString(R.string.conneting_server));
        txtDiscription.setText(getResources().getString(R.string.logging_in));
        dialog.setCancelable(false);
        dialog.show(); 
M S Gadag
  • 2,057
  • 1
  • 12
  • 15