Notice
Recent Posts
Recent Comments
Link
투케이2K
793. (Android/Java) [Alert] AlertDialog 팝업창 크기 Activity 커스텀 사이즈 지정 본문
[개발 환경 설정]
개발 툴 : AndroidStudio
개발 언어 : Java / Kotlin
[layout >> activity_a_alert_size_change.xml 파일]
---------------------------------------------------------------------------------------
[layout >> activity_a_alert_size_change.xml 파일]
---------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="#ff0000"
android:id="@+id/parent">
<!-- [editText 사용시 자동으로 포커스활성 방지]-->
<!-- android:focusable="true"-->
<!-- android:focusableInTouchMode="true"-->
<!-- android:id="@+id/parent"-->
</LinearLayout>
---------------------------------------------------------------------------------------
[JAVA 소스 코드 파일]
package com.example.javaproject;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
public class A_AlertSizeChangeView extends Activity {
/**
* // --------------------------------------------------------------------------------------
* TODO [클래스 설명]
* // --------------------------------------------------------------------------------------
* 1. 팝업창 사이즈 커스텀 설정 액티비티
* // --------------------------------------------------------------------------------------
* 2. AndroidManifest.xml 파일 적용 사항 :
*
* <activity
* android:name=".A_AlertSizeChangeView"
* android:theme="@android:style/Theme.Dialog"
* android:exported="true"/>
* // --------------------------------------------------------------------------------------
* 3. 인텐트 전환 :
*
* Intent intent = new Intent(A_Intro.this, A_AlertSizeChangeView.class);
* intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
* startActivity(intent);
* // --------------------------------------------------------------------------------------
* */
/**
* // --------------------------------------------------------------------------------------
* TODO [빠른 로직 찾기 : 주석 로직 찾기]
* // --------------------------------------------------------------------------------------
* // [SEARCH FAST] : []
* // --------------------------------------------------------------------------------------
*
* // --------------------------------------------------------------------------------------
*
* // --------------------------------------------------------------------------------------
*
* // --------------------------------------------------------------------------------------
*
* // --------------------------------------------------------------------------------------
*/
// -----------------------------------------------------------------------------------------
// TODO [컴포넌트 선언]
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
// TODO [전역 변수]
// -----------------------------------------------------------------------------------------
private static final String ACTIVITY_NAME = "A_AlertSizeChangeView";
// -----------------------------------------------------------------------------------------
// TODO [액티비티 onCreate]
// -----------------------------------------------------------------------------------------
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ===============================================================
S_Log._D_(S_FinalMsg.LOG_Activity_onCreate, new String[]{ S_FinalMsg.LOG_NOW() });
// ===============================================================
// ---------------------------------------------------------------
// [타이틀 바 없애기]
// ---------------------------------------------------------------
C_App.setTitleBarRemove(A_AlertSizeChangeView.this);
// ---------------------------------------------------------------
// [액티비티 레이아웃 지정 실시]
// ---------------------------------------------------------------
setContentView(R.layout.activity_a_alert_size_change);
// ---------------------------------------------------------------
// [액티비티 레이아웃 지정 실시] : [팝업창 사이즈 조절]
// ---------------------------------------------------------------
try {
// [팝업창 형태 크기 및 위치 커스텀 지정 실시]
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point point = new Point();
display.getSize(point);
int pointWidth = point.x;
int pointHeight = point.y;
int width = (int) (pointWidth * 1.0); // Display 사이즈의 100%
int height = (int) (pointHeight * 0.85); // Display 사이즈의 85%
getWindow().getAttributes().width = width; // 가로 크기
getWindow().getAttributes().height = height; // 세로 크기
getWindow().getAttributes().gravity = Gravity.BOTTOM; // 위치 설정
}
catch (Exception e){
e.printStackTrace();
}
// ---------------------------------------------------------------
// [컴포넌트 매핑 수행 실시]
// ---------------------------------------------------------------
} // TODO [메인 종료]
// -----------------------------------------------------------------------------------------
// TODO [액티비티 onResume]
// -----------------------------------------------------------------------------------------
@Override
public void onResume(){
super.onResume();
// ===============================================================
S_Log._D_(S_FinalMsg.LOG_Activity_onResume, new String[]{ S_FinalMsg.LOG_NOW() });
// ===============================================================
// ---------------------------------------------------------------
// 외부 브라우저 복귀 시 화면 전환 애니메이션 없애기 위함
// ---------------------------------------------------------------
try { overridePendingTransition(0, 0); } catch (Exception e){ e.printStackTrace(); }
}
// -----------------------------------------------------------------------------------------
// TODO [액티비티 onPause]
// -----------------------------------------------------------------------------------------
@Override
public void onPause(){
super.onPause();
// ===============================================================
S_Log._E_(S_FinalMsg.LOG_Activity_onPause, new String[]{ S_FinalMsg.LOG_NOW() });
// ===============================================================
// ---------------------------------------------------------------
// 외부 브라우저 복귀 시 화면 전환 애니메이션 없애기 위함
// ---------------------------------------------------------------
try { overridePendingTransition(0, 0); } catch (Exception e){ e.printStackTrace(); }
}
// -----------------------------------------------------------------------------------------
// TODO [액티비티 onDestroy]
// -----------------------------------------------------------------------------------------
@Override
public void onDestroy(){
super.onDestroy();
// ===============================================================
S_Log._E_(S_FinalMsg.LOG_Activity_onDestroy, new String[]{ S_FinalMsg.LOG_NOW() });
// ===============================================================
}
} // TODO [클래스 종료]
[결과 출력]
반응형
'Android' 카테고리의 다른 글
Comments