user3472001
user3472001

Reputation: 885

how to change dialog title font size

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();

Upvotes: 3

Views: 12148

Answers (3)

M S Gadag
M S Gadag

Reputation: 2057

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(); 

Upvotes: 0

AndroidEnthusiastic
AndroidEnthusiastic

Reputation: 931

Try This,

dialog2.setTextSize(14);

Upvotes: 0

jyomin
jyomin

Reputation: 1967

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);

Upvotes: 9

Related Questions