How to set AlertDialog custom title top margin and remove unwanted Padding? - android

I am stuck with a margin and padding issue of a title of AlertDialog.Builder, what i am doing is i want the title in center so i am using setCustomTitle i am able to do so but stuck with margin and padding of it. I don't want unwanted padding which is showing and also i want to set some top margin to title, i am using LinearLayout.LayoutParams but it has no effect. please suggest what to do to handle it.thanks
Code :
dialog = new AlertDialog.Builder(context, R.style.DialogTheme);
TextView title = new TextView(context);
title.setTextColor(ContextCompat.getColor(context, R.color.black));
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
title.setTypeface(Typeface.DEFAULT_BOLD);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 20, 0, 0);
title.setLayoutParams(lp);
title.setText("Dialog");
title.setGravity(Gravity.CENTER);
dialog.setCustomTitle(title);
dialog.setMessage("Dialog box with custom title view ");
dialog.setCancelable(false);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.show();
Result :

AlertDialog.Builder dialog = new AlertDialog.Builder(this);
TextView title = new TextView(this);
title.setTextColor(ContextCompat.getColor(this, android.R.color.black));
title.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
title.setTypeface(Typeface.DEFAULT_BOLD);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 20, 0, 0);
title.setPadding(0,30,0,0);
title.setLayoutParams(lp);
title.setText("Dialog");
title.setGravity(Gravity.CENTER);
dialog.setCustomTitle(title);
dialog.setMessage("Dialog box with custom title view ");
dialog.setCancelable(false);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
}
});
dialog.show();
Replace this code it will work

You can avoid setting up all this methods to your AlertDialog by using DialogFragment. Just use getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); in onCreateView method and make your own custom view for the dialog in the way you create a common fragment. It's a better way to make proper dialogs.

I suggest you to use DialogFragment to show custom layout as alert Dialog its very easy and we can customize our dialog as per requirement..for more detail about it : https://developer.android.com/reference/android/app/DialogFragment.html
Below is the layout as per your requirement, You can use the below xml layout to show your custom layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/margin10dp"
android:layout_weight="1"
android:gravity="center"
android:text="My Dialog"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:padding="10dp">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="My Dialog Box Description !"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2"
android:background="#android:color/transparent"
android:text="OK"
android:textSize="22dp" />
</RelativeLayout>
</RelativeLayout>

Related

Android Pop Up during opening of Application

I am developing an Android application, where I need to show a popup containing some message on application opening (Image attached for reference).
I have tried to achieve this using toast message and snack bar but could not do exact same.
Please suggest which component in Android to be used to achieve this functionality?
You can achieve the desired results using a dialog. I am sharing the code, you can modify it as you want but make sure you put it inside the onCreate method of the launcher activity.
This is the code for a simple dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Look at this dialog!")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//do things
}
});
AlertDialog alert = builder.create();
alert.show();
The one shown in the picture shared by you is a custom dialog where you have to make your own layout. Here is an example,
1. Create your own layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffffff">
<ImageView
android:layout_width="match_parent"
android:layout_height="120dp"
android:id="#+id/a"
android:gravity="center"
android:background="#DA5F6A"
android:src="#drawable/dialog_cross"
android:scaleType="fitCenter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="#+id/text_dialog"
android:layout_below="#+id/a"
android:layout_marginTop="20dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="20dp"
android:textSize="18sp"
android:textColor="#ff000000"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal" />
<Button
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="OK"
android:id="#+id/btn_dialog"
android:gravity="center_vertical|center_horizontal"
android:layout_below="#+id/text_dialog"
android:layout_marginBottom="20dp"
android:background="#drawable/btn_flat_red_selector"
android:layout_centerHorizontal="true"
android:textColor="#ffffffff" />
</RelativeLayout>
2. Create a class for the custom dialog
public class ViewDialog {
public void showDialog(Activity activity, String msg){
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.dialog);
TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
text.setText(msg);
Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog);
dialogButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
}
3. Make an object in your launcher activity of the custom dialog class and call the function showDialog
ViewDialog alert = new ViewDialog();
alert.showDialog(getActivity(), "Thank you for installing the Paytm
App");
Or you could use an external library for getting the desired results
Pop.on(this).with().title(R.string.title).layout(R.layout.custom_pop).show();
where R.layout.custom_pop is the custom layout of your dialog.
Try this for same result:
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:id="#+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Hello, this is your message"
android:textSize="20sp" />
</LinearLayout>
code:
private void showDialog() {
final Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.dialog);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.BOTTOM;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
dialog.findViewById(R.id.btnClose).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
dialog.cancel();
}
});
dialog.show();
}

How to customise android dialogs to material theme?

I wanted to customise android Dialog to make it look like a floating dialog as below which is suggested in https://material.google.com/components/dialogs.html#dialogs-simple-dialogs
I tried creating a DialogFragment in which onCreateDialog returns a Dialog with a view whose root is a CardView.But couldn't get the expected result.Can I have some suggestions on how to achieve this?
My layout looks like this,
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|top"
card_view:cardElevation="5dp"
card_view:cardPreventCornerOverlap="false">
//Contents come here
</android.support.v7.widget.CardView>
and in code,
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getActivity());
View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_font_selection,null,false);
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(view);
float width = (I am getting screen width here) * .80f;
dialog.getWindow().setLayout((int) width, ViewGroup.LayoutParams.WRAP_CONTENT);
return dialog;
}`
but the result looks like this,
Instead of getting elevation I was getting a black shade
AlertDialog.Builder mydialog = new AlertDialog.Builder( context);
mydialog.setTitle("Set backup accounts");
mydialog.setItems(CharSequence[] items, OnClickListener);
mydialog.show();
mydialog.setContentView(R.layout.mydialogLayout);
This in your activity/fragment. And so declare your layout as follow:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:id="#+id/myID1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
After that, if you want to handle the clicks just do that:
TextView myView1 = (TextView) mydialog.findViewById(myID1);
myView1.setOnClickListener(...);
MaterialAlertDialogBuilder is now available for Android:
material.io/develop/android/components/dialog

Android Custom AlertDialog not drawn correctly

I'm trying to customise the appearance of an AlertDialog. The problem is that I don't know how to get rid of the black lines that appear above my first TextView and EditText at the bottom (above the grey button regions).
Here is is my XML. What am I missing?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#color/butGreyBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="30"
android:text=""
android:background="#00000000"
android:textColor="#android:color/white"
android:textSize="22sp"
android:layout_margin="0dp"
android:gravity="center" />
<TextView
android:id="#+id/tv_prompt"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="30"
android:text=""
android:background="#00000000"
android:textColor="#android:color/white"
android:textSize="18sp"
android:layout_margin="0dp"
android:gravity="center" />
<EditText
android:id="#+id/edit_text"
android:inputType="textCapSentences|textAutoCorrect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"/>
</LinearLayout>
Here's the code too - which is probably where the problem lies:
View alertView;
AlertDialog.Builder builder = new AlertDialog.Builder( mContext );
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
alertView = inflater.inflate(R.layout.alert_dialog_text, null);
builder.setView( alertView );
AlertDialog alertDialog = builder.create();
alertDialog.setView( alertView, 0,0,0,0 );
final EditText input = (EditText) alertView.findViewById( R.id.edit_text );
TextView tvTitle = (TextView) alertView.findViewById( R.id.tv_title );
TextView tvPrompt = (TextView) alertView.findViewById( R.id.tv_prompt );
tvTitle.setText( "Rename Playlist" );
tvPrompt.setText( "Enter new Playlist name." );
// Set up the buttons
builder.setPositiveButton( "OK", new DialogInterface.OnClickListener()
{
#Override
public void onClick( DialogInterface dialog, int which )
{
mNewName = input.getText().toString();
}
} );
builder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener()
{
#Override
public void onClick( DialogInterface dialog, int which )
{
mNewName = "";
dialog.cancel();
}
} );
builder.show();
#sparky...
1) xml in Values Folder and add this code
wrap_content
wrap_content
#color/transparent1
false
true
and make a reference this Theme to Your Dialog Like this
Dialog dialog = new Dialog(activity, R.style.CustomDialogTheme);
then set Your custom Dialog Layout Xml file as setContentView.
dialog.setContentView(R.layout.customdialog);
2)you are not closing the parent LinearLayout at the end
and you are using #000000 color code for parent layout this will display black color at background
try to change the color code you bottom color will chance. and use
requestWindowFeature(Window.FEATURE_NO_TITLE);
in you dialog class this will remove the dialog title so your top color also will remove..
Let me know if you need any help
Thanks
I fixed this in the end by implementing my own custom dialog instead of using the AlertDialog.

How can I create my own theme for alertDialog?

I want to create a different theme for all of alertDialog instances. I need my own title view instead of the usual black title background. All text should have a blue color, and set the edge of the alertDialog to a round shape.
Is it possible to create our own theme for alert dialogs, using any style or creating a class which extends AlertDialog.Builder? I need a common theme or style for my all instances of alertDialog. I am using alertDialog in many places - one for singleChoice items, one with ArrayAdapter.
My alertDialog with array adapter:
String[] items = {"Edit profile","Change user","Change password","Logout"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Loged.this,
R.layout.my_spinner_layout, items);
settingMenu.setAdapter(adapter, listener);
My alertDialog with single choice items:
alertDelete = new AlertDialog.Builder(getParent());
alertDelete.setTitle("Delete");
alertDelete.setCancelable(true);
CharSequence[] choice = {"this user","All user"};
alertDelete.setSingleChoiceItems(choice, 0,
For my all alertDialog, I need a common theme, like:
please check this link. here am creating my own alertDialog class
and its a simple method if you reuse the alertDialog in many situation in your application
how Create setAdapter() for a AlertDialog
I solved my problem by creating a class which extends Dialog, and I created my own functions. for example setMessage,setTitle,setPositiveButton,setNegativeButton etc.
But am confusing on how we can replace the setAdapter() and setSingleChoice().
Here one example For Dialog:
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom);
dialog.setTitle("Give a Title...");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Put here any custom text!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
Button dialogButton = (Button) dialog.findViewById(R.id.ButtonOK);
// if button is clickedthen dialog will closed
dialogButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
Custom AlertDialog
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext;
LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View urlayoutfile = inflater.inflate(R.layout.custom_dialog_xmlfile,(ViewGroup)findViewById(R.id.Yourlayout_id));
builder = new AlertDialog.Builder(this);
builder.setView(urlayoutfile);
alertDialog = builder.create();
alertDialog.show();
To use a specific style, use
ctw = new ContextThemeWrapper(this, R.style.MyStyle);
new AlertDialog.Builder(ctw)
.setTitle(...)
You can use layout as Different themes, styles, Backgrounds
customdialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout1"
style="#android:style/Theme.Black.NoTitleBar.Fullscreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/layoutsample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/dialoghdrbg"
android:orientation="horizontal" >
<ImageView
android:id="#+id/dialogheaderimage1"
android:layout_width="50dp"
android:layout_height="48dp"
android:scaleType="fitXY"
/>
<TextView
android:id="#+id/dialogheadertext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:layout_marginLeft="1dp"
android:gravity="center_vertical|right"
android:textColor="#000000"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/dialogcontentbg"
android:orientation="vertical" android:gravity="center">
<TextView
android:id="#+id/dialogmessgetext1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#ffffff"
android:textSize="23dp"
android:text=""
android:gravity="center"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal"
android:gravity="center|center_horizontal"
android:layout_marginTop="20dip"
android:orientation="horizontal">
<Button
android:id="#+id/dialogokbutton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:background="#drawable/buttonanimation"
android:text="Retry"
android:textSize="20dp"
android:textStyle="bold" />
<Button
android:id="#+id/dialogcancelbutton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/buttonanimation"
android:text="Report"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
customDialog.java
final Dialog favDialog = new Dialog(Myclass.this,
android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
favDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
favDialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
favDialog.setContentView(R.layout.reloadurlpopuplayout);
favDialog.setCancelable(false);
ImageView dialogImage = (ImageView) favDialog
.findViewById(R.id.dialogheaderimage1);
dialogImage.setBackgroundResource(R.drawable.questionmark);
TextView dialogMesage = (TextView ) favDialog
.findViewById(R.id.dialogmessgetext1);
TextView dialogHeader = (TextView) favDialog
.findViewById(R.id.dialogheadertext1);
String descText = getString(R.string.RetryReportMessage);
dialogMesage.setBackgroundColor(0x00000000);
dialogMesage.setText(descText);
dialogHeader.setText(R.string.BrockenLinkHeader);
try {
favDialog.show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Android not sizing Custom Dialog big enough

I am using a custom Dialog that contains a text field, an image, and a button. The text can contain HTML. Sometimes the bottom of the dialog gets chopped off the bottom when the text is long enough. How can I prevent this? I want Android to determine the size of the dialog but it doesn't seem to be doing that. DO I need to size the Dialog myself in this case?
Here is the layout...
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/alert_root_incorrect"
style="#style/AlertDialogTheme"
android:background="#drawable/rounded_alert"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/rounded_alert"
>
<TableLayout
android:stretchColumns="0"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textStyle="bold"
android:text="Sorry, that's wrong!"
android:textColor="#color/gray_dark" />
<ImageView
android:id="#+id/check"
android:background="#drawable/xmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp" />
</TableRow>
</TableLayout>
<TextView
android:id="#+id/alert_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:text="In fact, this is where the explanation will go. Something about how this passage related to the topic"
android:textColor="#000000" />
<Button
android:id="#+id/okay_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:background="#drawable/rounded_alert_button"
android:text="Okay"
android:textColor="#color/white"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
And here is the code I am using to load it...
if ( null == layout ) {
this.layout = inflater.inflate(R.layout.alert_incorrect, (ViewGroup) findViewById(R.id.alert_root_incorrect));
}
TextView message = (TextView) layout.findViewById(R.id.alert_text);
message.setText(Html.fromHtml(card.getConclusion()));
((Button) layout.findViewById(R.id.okay_button)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dismissDialog(INCORRECT_DIALOG);
nextQuestion();
}
});
layout.requestLayout();
dialog = new Dialog(this, R.style.AlertDialogTheme);
dialog.setContentView(layout);
dialog.setCancelable(false);
return dialog;
And here's a snap of what I mean..
Thanks,
John
This is not perfect but I've corrected it by setting the layout of the dialog relative to the default display.
dialog = new Dialog(this, R.style.AlertDialogTheme);
dialog.setContentView(layout);
Window window = dialog.getWindow();
window.setLayout(
(int)(window.getWindowManager().getDefaultDisplay().getWidth() * .90),
(int)(window.getWindowManager().getDefaultDisplay().getHeight() * .90 ));
dialog.setCancelable(false);
Just tweak the ".90" values until it feels right.
Here is the solution:
You should add a Linearlayout at the outside of your dialog's xml file
Then set this Linearlayout's gravity as "center"
the last step is creating a LayoutParams and set it to the dialog
android.view.WindowManager.LayoutParams lp = new android.view.WindowManager.LayoutParams();
lp.width = android.view.WindowManager.LayoutParams.FILL_PARENT;
lp.height = android.view.WindowManager.LayoutParams.FILL_PARENT;
alertDialog.getWindow().setAttributes(lp);

Categories

Resources