본문 바로가기
#모바일 [Mobile]/Android

[Android] Custom Dialog 띄우기 (How to create a Custom Dialog in android?)

by cy_mos 2019. 8. 7.
반응형

https://www.codingdemos.com/android-custom-dialog-animation/


📄 Create a custom dialog in android Source Code by Java

public class CustomDialog extends Dialog implements View.OnClickListener {

    public CustomDialog(@NonNull Context context) {
        super(context);

        requestWindowFeature(Window.FEATURE_NO_TITLE);   // 다이얼로그의 타이틀바를 없애주는 옵션입니다.
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));  // 다이얼로그의 배경을 투명으로 만듭니다.
        setContentView(R.layout.here_layout_name);     // 다이얼로그에서 사용할 레이아웃입니다.
    }
    
}

final CustomDialog dialog = new CustomDialog(this);

WindowManager.LayoutParams mWindowManager = dialog.getWindow().getAttributes();  // Setting Dialog Width and Height.
mWindowManager.copyFrom(dialog.getWindow().getAttributes());

/* TODO: - Setting Dialog Width/Height Lines
  final DisplayMetrics mDisplayMetrics = getApplicationContext().getResources().getDisplayMetrics(); // Get Device Display Size
  final int width = mDisplayMetrics.widthPixels; // Device Display Width
  final int height = mDisplayMetrics.heightPixels; // Device Display Height

  mWindowManager.width = width / 2;
  mWindowManager.height = height / 2;
*/

dialog.show();

🚀 REFERENCE

 

대화상자  |  Android Developers

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design For…

developer.android.com

 

How to create a Custom Dialog box in android?

I want to create a custom dialog box like below I have tried the following things. I created a subclass of AlertDialog.Builder and used a custom Title and Custom Content View and used that but the

stackoverflow.com

 

Android Custom Dialog With Animation - Coding Demos

Learn how to create an Android custom dialog with left-right animation. You will build an Alertdialog with Imageview, background color, TextView and Button.

www.codingdemos.com

 

반응형

댓글