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

  • SEARCH
  • Home
  • 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 7568955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:03:40+00:00 2026-05-30T15:03:40+00:00

In my application I have a custom dialog which display some unwanted margin at

  • 0

In my application I have a custom dialog which display some unwanted margin at the top whereas in xml, I have not defined any kind of margin or padding to the top. Still my dialog looks like this –
enter image description here

The code for the same is like –

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/customDialogRelativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dip"
            android:layout_marginRight="15dip"
            android:textStyle="bold"
            android:layout_alignParentTop="true"
            android:textColor="@color/white"
            android:textSize="22sp"/>

        <View
            android:id="@+id/view_separator_in_dialog"
            style="@style/dialog_separator"
            android:layout_width="fill_parent"
            android:layout_height="1dip"
            android:visibility="gone" />

        <TextView
            android:id="@+id/tv_message"
            style="@style/dialog_message"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:visibility="gone" />

        <EditText
            android:id="@+id/et_input_text"
            style="@style/dialog_edittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/tv_message"
            android:paddingLeft="10dip"
            android:visibility="gone" />

        <TextView
            android:id="@+id/tv_caption"
            style="@style/dialog_caption"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/et_input_text"
            android:visibility="gone" />

        <LinearLayout
            android:id="@+id/rl_dialog_buttons_horizontal"
            style="@style/dialog_rl_buttons"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/btn_left_dialog"
                style="@style/dialog_button_left"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:visibility="gone" />

            <Button
                android:id="@+id/btn_right_dialog"
                style="@style/dialog_button_right"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:visibility="gone" />

        </LinearLayout>
</RelativeLayout>

I want that unnecessary gap over the “Confirmation” text to be removed.

The class that raises the dialog is like –

public class MyClass extends Activity{

private View _separator;
private CustomDialogBox _dialog;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.custom_dialog);

    Object[] data = new Object[]{"Confirmation!", "Contact with this number already exits. Do you want to merge?", "Merge", "Create New"};
    raiseDailog(this, data);
}

private void raiseDailog(Context context, Object[] data) {
    _dialog = new CustomDialogBox(this, data);
    _dialog.show();
}

}

And my CustomDialog class looks like –

public class CustomDialogBox extends Dialog{

private TextView _title, _message;
private Button _leftButton, _rightButton;
private View _separator;

private String textviewTop;
private String textviewMiddle;
private String buttonText1;
private String buttonText2;

public CustomDialogBox(Context context, Object[] data) {
    super(context);

    setContentView(R.layout.custom_dialog);
    initializeViews();
    fillData(data);
}

private void fillData(Object[] data) {
    try {
        int i = 0;
        textviewTop = (String) data[i++];

        textviewMiddle = (String) data[i++];

        buttonText1 = (String) data[i++];
        buttonText2 = (String) data[i++];
    } catch (Exception e) {
        e.printStackTrace();
    }

    generateDialog();
}

private void generateDialog() {
    //Title goes here
    _title.setVisibility(View.VISIBLE);
    _title.setText(textviewTop);

    //Separator goes here
    _separator.setVisibility(View.VISIBLE);

    //Message goes here
    _message.setVisibility(View.VISIBLE);
    _message.setText(textviewMiddle);

    //Ok button goes here
    _leftButton.setVisibility(View.VISIBLE);
    _leftButton.setText(buttonText1);

    //Cancel button goes here
    _rightButton.setVisibility(View.VISIBLE);
    _rightButton.setText(buttonText2);
}

private void initializeViews() {
    _title = (TextView) findViewById(R.id.tv_title);
    _message = (TextView) findViewById(R.id.tv_message);

    _leftButton = (Button) findViewById(R.id.btn_left_dialog);
    _rightButton = (Button) findViewById(R.id.btn_right_dialog);

    _separator = findViewById(R.id.view_separator_in_dialog);
}

}

Please help.

  • 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-30T15:03:41+00:00Added an answer on May 30, 2026 at 3:03 pm

    Add this this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    Like As,,

     public CustomDialogBox(Context context, Object[] data) {
            super(context);
    
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.custom_dialog);
            initializeViews();
            fillData(data);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking into some XSS prevention in my Java application. I currently have custom
I have a custom built application framework written in PHP which I have been
I am showing a custom dialog in my application, which stays for a small
I have a custom dialog in my android application. I want to have in
I have created a custom dialog box which requires 3 fields public class Test{
For any custom dialog (form) in a WinForm application I can set its size
In my WPF application I have a lot of custom dialog boxes that pop
I'm doing some custom printing using a PrintDocument in my application. I have a
I have a custom dialog with some buttons and I would like to set
Many applications have dialogs which have totally custom-looking dialogs, big fat tool-bars and non-rectangular

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.