3

I'm trying to create custom AlertDialog with an image text and buttons. When I display it I get a white border which looks horrible.

enter image description here

How can I get rid of that white border?

Here my custom Dialog:

public LinearLayout customeLL;
    public void  alertD()
    {
        AlertDialog ad;
        AlertDialog.Builder  builder;
        Context mContext = getApplicationContext();
        TextView a = new TextView(getApplicationContext());
        a.setText("Test dialog");
        ImageView img = new ImageView(getApplicationContext());
        img.setBackgroundResource(R.drawable.bottombar_bg);
        LinearLayout customeLL = new LinearLayout(getApplicationContext());
        customeLL.setOrientation(LinearLayout.VERTICAL);
        customeLL.addView(img,curWidth,37);
        customeLL.addView(a,curWidth,37);
        builder = new AlertDialog.Builder(myClass.this);
        builder.setView(customeLL);
        ad=builder.create();
        ad.show();

    }

As you can see the topborder and image have a space in 2-3 px.

6
  • what do you mean by white boreder?
    – ingsaurabh
    May 6, 2011 at 10:47
  • just a border . Border in alertDialog ( default it's white border)
    – Peter
    May 6, 2011 at 10:48
  • you can use Dialog instead of Alert..? May 6, 2011 at 11:12
  • sure, if there i can remove folder :(. But all guys said me i must create custom in alertdialog . (for image instead title) . I want just have in vertical style : image (instead title) , text1,text2,text3,btn1,btn2 ....
    – Peter
    May 6, 2011 at 11:13
  • you can add layout in Dialog whatever you want.. May 6, 2011 at 11:18

3 Answers 3

9

try this use Dialog Instead of AlertDialog.Builder

.. for remove border line from Dialog..

Dialog dialog = new Dialog(this,android.R.style.Theme_Translucent_NoTitleBar);
2
  • thanks,but it's remove only title. I need remove border :(( Please see on image in top- white line - it's possible to remove ?????
    – Peter
    May 6, 2011 at 11:39
  • I've just published a gist showing a floating Dialog with custom theme, no title or border: gist.github.com/2643546 May 9, 2012 at 10:20
2

This will remove borders:

AlertDialog ad;
ad= new AlertDialog.Builder(context).create();
ad.show();
ad.setContentView(R.layout.dialog_layout); // set your custom layout

// Then initialize your dialog views like this
TextView txt= (TextView) ad.findViewById(R.id.dialog_text); // a TextView inside dialog 
                                                            // layout
txt.setText("I'm a custom dialog!");

Also, I had a problem using a custom Dialog in full screen mode. my phone's notification bar kept showing up as long as the dialog wasn't dismissed. with a customized AlertDialog, this won't be an issue ;)

0

If you want the Dialog Border to appear in any colour you wish you have to use layout style and a theme. There is an excellent article about it here: http://blog.androgames.net/10/custom-android-dialog/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.