有没有一种方法可以使用XML或编程方式将GUI屏幕(活动)设置为200dip宽和150dip高?Android:如何设置活动窗口的绝对大小?
我找到了getWindow()。setLayout(),但只为宽度和高度预定义常量。
有没有一种方法可以使用XML或编程方式将GUI屏幕(活动)设置为200dip宽和150dip高?Android:如何设置活动窗口的绝对大小?
我找到了getWindow()。setLayout(),但只为宽度和高度预定义常量。
您可以在Window.setLayout()中使用绝对数字,就像您在其他地方指定布局宽度和高度一样。对不起,该文件不明确。
只需使用全屏布局,并在里面定义另一个具有所需大小的布局。有点像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="200dip"
android:layout_height="150dip">
<Button android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
我在里面放了一个按钮来显示内容的位置。
WindowManager.LayoutParams params = getWindow().getAttributes();
params.x = 0;
params.height = 650;
params.width = totalWidth;
params.y = totalHeght/10;
this.getWindow().setAttributes(params);
可能是它的工作原理......但要确保有关的价值观......
我想你的片断,但窗口的大小设置为全屏。我想能够控制实际的窗口大小,使它有点像一个对话框。 – zer0stimulus 2010-12-15 22:48:41