Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6210539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:10:39+00:00 2026-05-24T06:10:39+00:00

AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(Title); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,

  • 0
AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Title");
        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
            }
        });
        AlertDialog alert = builder.create();

I am using the above code to display an Alert Dialog. By default, it fills the screen in width and wrap_content in height.
How can I control the width and height of default alert dialog ?
I tried:

alert.getWindow().setLayout(100,100); // It didn't work.

How to get the layout params on the alert window and manually set the width and height?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:10:39+00:00Added an answer on May 24, 2026 at 6:10 am

    Only a slight change in Sat Code, set the layout after show() method of AlertDialog.

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(layout);
    builder.setTitle("Title");
    alertDialog = builder.create();
    alertDialog.show();
    alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
    

    Or you can do it in my way.

    alertDialog.show();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    
    lp.copyFrom(alertDialog.getWindow().getAttributes());
    lp.width = 150;
    lp.height = 500;
    lp.x=-170;
    lp.y=100;
    alertDialog.getWindow().setAttributes(lp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

@Override protected Dialog onCreateDialog (int id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.instant_alert_screen_title); builder.setInverseBackgroundForced(true);
I have this simple code: AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle (Alert title); dialog.setMessage
new AlertDialog.Builder(this) .setMessage(mymessage) .setTitle(title) .setCancelable(true) .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int
Here is my code: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this;
I've got this dialog (I'm simplifying my use case): class EditShoppingListDialog extends AlertDialog {
this is a part of my code : public void onItemClick(AdapterView<?> parent, View v,
Yes, I know there's AlertDialog.Builder, but I'm shocked to know how difficult (well, at
I'd like to use AlertDialog as a Login or pin code or password dialog.
I have an AlertDialog.Builder displaying on an application. When I rotate the screen, I
I'm trying to create a what's new pop-up dialog when users update (or, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.