views:

32

answers:

1

I created a custom dialog that I'm dynamically putting views into via a RelativeLayout. Every time the dialog is displayed, it shows all my child views just great, but it has some space at the top that I can not account for. I'm assuming this is reserved for a "title" of the dialog (which I won't have). Is there a way to remove that space and have my custom dialog just wrap the contents that I'm putting in?

here is the xml for the layout:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">
  <RelativeLayout
     android:id="@+id/handlay"
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" />  
</LinearLayout>

incidentally, I've tried just having the relative layout be the parent node, with the same results.

Here is the .java for the custom dialog.

public class HandResults extends Dialog implements DialogInterface {
    HandResults hr;
    Timer myTimer;
    RelativeLayout handrl;


    // constructor sets the layout view to handresult layout
    public HandResults(Context context) {
        super(context);
        setContentView(R.layout.handresults);
        hr = this;

    }

    // create a timer to remove the dialog after 3 seconds
    public void showHands(){
        this.show();
        myTimer = null;
        myTimer = new Timer();
        myTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                hr.cancel(); 
            }
        }, 3000);

    }
}

and here is how I would call the dialog:

HandResults mhr = new HandResults(this);
mhr.showHands();

no matter what I do or how I change the layout file, I always have that buffer at the top, how can I get rid of that?

A: 

Put this code into class contstructor or onCreate() method:

    requestWindowFeature(Window.FEATURE_NO_TITLE);

It must be before calling setContentView method.

radek-k
awesome..this is perfect thanks!
Kyle