---
title: "android的activity或dialog位置大小动态显示"
author: "runfeel"
date: "2011-10-26T15:27:00Z"
tags: []
slug: "android-activity-dialog"
draft: false
lastmod: "2013-07-11T13:40:09Z"
id: 1903702
url: "https://runfeel.iteye.com/blog/1903702"
---

```
WindowManager.LayoutParams layoutParams = getWindow().window.getAttributes();
layoutParams.width = WINDOW_WIDTH;	//修改窗体宽高
layoutParams.height = WINDOW_HEIGHT;
layoutParams.alpha = WINDOW_ALPHA;		//修改窗体透明度
layoutParams.x = x;	//修改窗体显示的位置
layoutParams.y = y;
需要注意的是，窗体显示的初始位置是窗体的中心在屏幕的中心位置上，此时layoutParams.x和layoutParams.y都是0。
```