当前位置:编程学习 > JAVA >>

android中用java代码动态控制activity的大小,位置,透明度

 

Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 

 Window window = getWindow(); 

LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 

windowLayoutParams.width = (int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95  

windowLayoutParams.height = (int) (display.getHeight() * 0.1); // 高度设置为屏幕的0.6 

windowLayoutParams.alpha = 0.5f;// 设置透明度 

 

 

摘自:tao_zi7890的专栏

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,