Android Dialog 화면 꽉채우기
2020. 12. 7. 21:41
Programing/Android
화면조절 코드
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog_restinfo, null);
layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f));
layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f));
Dialog 전체코드
public class DialogRestInfo {
private Context context;
public DialogRestInfo(Context context) {
this.context = context;
}
public void callFunction(RestListDTO dto) {
// 커스텀 다이얼로그를 정의하기위해 Dialog클래스를 생성한다.
final Dialog dlg = new Dialog(context);
// 액티비티의 타이틀바를 숨긴다.
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = dlg.getWindow();
Rect displayRectangle = new Rect();
window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
// inflate and adjust layout
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog_restinfo, null);
layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f));
layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f));
dlg.setContentView(layout);
dlg.setCancelable(true);
// 커스텀 다이얼로그를 노출한다.
dlg.show();
// 커스텀 다이얼로그의 각 위젯들을 정의한다.
final TextView tvrestName = (TextView) dlg.findViewById(R.id.info_tvRestname);
final TextView tvrestSpace = (TextView) dlg.findViewById(R.id.info_tvRestspace);
final TextView tvrestAddr = (TextView) dlg.findViewById(R.id.info_tvRestaddr);
final TextView tvrestTell = (TextView) dlg.findViewById(R.id.info_tvResttell);
final TextView tvrestetc = (TextView) dlg.findViewById(R.id.info_tvRestetc);
final ListView menuListview = (ListView) dlg.findViewById(R.id.info_listMenu);
final Button btnBack = (Button)dlg.findViewById(R.id.btnBack);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dlg.dismiss();
}
});
tvrestName.setText(dto.getR_name());
tvrestSpace.setText(dto.getR_space());
tvrestAddr.setText(dto.getR_addr());
tvrestTell.setText(dto.getR_tell());
tvrestetc.setText(dto.getR_etc());
}
}
'Programing > Android' 카테고리의 다른 글
Android Intent startActivityForResult (0) | 2020.12.07 |
---|---|
Android HTML, 외부주소에서 JSON 파싱해 가져오기 (0) | 2019.12.28 |
Android 리스트뷰 (0) | 2019.12.28 |
assets 사전 insert DB (0) | 2019.12.09 |
Adapter, GridView와 ListView 적용법 (0) | 2019.11.25 |