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 3316676
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:29:52+00:00 2026-05-17T22:29:52+00:00

So I see we can have alertdialogs with gray and white (when setinverse…) background

  • 0

So I see we can have alertdialogs with gray and white (when setinverse…) background colors.

To learn why I checked themes.xml of the sdk, checking it I was led to drawables and there I realized the alertdialog background is not done programatically but via some images. And these images guarantee that there are two gray(or white when inverse color) horizontal lines on top(title area) and bottom(just above button area) of the dialog when we use LayoutInflater to just set a different backgroundcolor.

So my question is, as LayoutInflator is useless and guessing I have to subclass alertdialog, what do you suggest I do to generate an AlertDialog with a different backgroundcolor? What should I override?

  • 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-17T22:29:52+00:00Added an answer on May 17, 2026 at 10:29 pm

    Instead of using AlertDialog, I ended up using a Dialog. To get a custom look:

    1-Create the Dialog and remove the title area(Otherwise you’ll get a blank gray area on top):

    myDialog = new Dialog(this);
    myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    

    2-Design a layout in xml, and set as dialog’s content:

    myDialog.setContentView(R.layout.mydialog_layout);
    

    3-If the layout is not a rounded rect, it will intersect with the rounded corners of the dialog box. So, design the layout as a rounded rect:

    in mydialog_layout.xml:

    android:background = "@layout/mydialog_shape"
    

    mydialog_shape.xml:

    <?xml version="1.0" encoding="UTF-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
         android:shape="rectangle" 
         > 
         <gradient android:startColor="#FF0E2E57" 
         android:endColor="#FF0E2E57" 
                android:angle="225" android:paddingLeft="20dip"/> 
    
        <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" 
         android:topLeftRadius="5dp" android:topRightRadius="5dp" android:paddingLeft="20dip"/> 
    </shape>
    

    4-Add listeners to the buttons in your activity:

    Button button = (Button)myDialog.findViewById(R.id.dialogcancelbutton);
    button.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        myDialog.cancel();
    }});
    

    That’s about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.