Im creating a custom Dialog. But it is showing extra space around.
Code:
private void showPushAlert(Context context, String message, int layoutID) {
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(layoutID);
TextView tvPushMessage = (TextView) dialog.findViewById(R.id.tvAlertMessage);
tvPushMessage.setText(message);
Button btnPushOk = (Button) dialog.findViewById(R.id.btnAlertOk);
btnPushOk.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.show();
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:background="@drawable/background_round_rectangle"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/tvAlertMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" />;
<Button
android:id="@+id/btnAlertOk"
android:layout_width="65dp"
android:layout_height="30dp"
android:layout_below="@id/tvAlertMessage"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="@drawable/btn_use"
android:text="@string/ok"
android:textColor="@color/white" />
</RelativeLayout>
I also tried inflater:
final Dialog dialog = new Dialog(context);
View view = getLayoutInflater().inflate(layoutID, null);
dialog.setContentView(view);
But not the perfect result. Jut the width stretched. I wanted to keep simple, so used just Dialog, instead of AlertDialog, or Dialog fragment.