赞
踩
1
2
3
4
|
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
int
screenWidth = display.getWidth();
int
screenHeight = display.getHeight();
|
下面的代码片段是我自己在程序中写死布局使用的,仅供参考:
Button cancelBtn =
new
Button(
this
);
if
(screenWidth<
320
|| screenHeight<
320
)
cancelBtn.setLayoutParams(
new
LayoutParams(
60
,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
else
if
(screenWidth <
480
&&screenHeight ==
480
)
cancelBtn.setLayoutParams(
new
LayoutParams(
80
,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
else
if
(screenWidth >
480
&& screenHeight ==
480
)
cancelBtn.setLayoutParams(
new
LayoutParams(
160
,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
else
cancelBtn.setLayoutParams(
new
LayoutParams(
120
,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。