See the screen shot the dialog is not showing center vertically and unexpected margin
I have tried many example but no one solve this. please refer to screen shot so you will understand very easy,what my problem is. "As you see - Dialog appear with unexpected margin"
i have also try this
Window window = dialog.getWindow(); window.setLayout(AppBarLayout.LayoutParams.WRAP_CONTENT, AppBarLayout.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.CENTER);
java code is -
final Dialog dialog = new Dialog(MainActivity.this);
dialog.setContentView(R.layout.dialogforgot_password);
final EditText et_emailforgot = (EditText)dialog.findViewById(R.id.et_EnterMail);
final Button bt_SubmitForgotPass = (Button)dialog.findViewById(R.id.bt_SubmitForgotButton);
final TextView ForgotHeading = (TextView)dialog.findViewById(R.id.tv_forgotpasswordHeading);
final TextView PleaseEnterurMail = (TextView)dialog.findViewById(R.id.tv_Enteruremail);
et_emailforgot.setTypeface(Lato_Regular);
PleaseEnterurMail.setTypeface(Lato_Regular);
ForgotHeading.setTypeface(Lato_Bold);
bt_SubmitForgotPass.setTypeface(Lato_Bold);
dialog.show();
and my XML file is as Follows:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_windowcorner"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/rounded_headingcorner"
android:layout_alignParentTop="true"
android:id="@+id/RLForgot">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password"
android:textColor="#ffffff"
android:textSize="16dp"
android:id="@+id/tv_forgotpasswordHeading"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please Enter Your Registered Email id"
android:textColor="#000000"
android:textSize="17dp"
android:layout_marginRight="22dp"
android:layout_marginLeft="22dp"
android:id="@+id/tv_Enteruremail"
android:layout_centerHorizontal="true"
android:layout_below="@+id/RLForgot"
android:layout_marginTop="20dp"
android:textAlignment="center"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:textAlignment="center"
android:id="@+id/et_EnterMail"
android:hint="Enter Your Email Id Here"
android:singleLine="true"
android:background="@drawable/custom_spinner_background"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:layout_below="@+id/tv_Enteruremail"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Submit"
android:background="@drawable/signin_btn"
android:textColor="@color/signinlogcolor"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/bt_SubmitForgotButton"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:layout_below="@+id/et_EnterMail"
android:layout_centerHorizontal="true" />
</RelativeLayout>
what my problem is. "As you see - Dialog appear with unexpected margin"
it is called Dialog
title Use dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
to remove title from Dialog
like below code
Try this
final Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialogforgot_password);