2010-12-15 91 views

回答

10

您可以在Window.setLayout()中使用绝对数字,就像您在其他地方指定布局宽度和高度一样。对不起,该文件不明确。

2

只需使用全屏布局,并在里面定义另一个具有所需大小的布局。有点像这样:

<?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> 

我在里面放了一个按钮来显示内容的位置。

+0

我想你的片断,但窗口的大小设置为全屏。我想能够控制实际的窗口大小,使它有点像一个对话框。 – zer0stimulus 2010-12-15 22:48:41

3
WindowManager.LayoutParams params = getWindow().getAttributes(); 
     params.x = 0; 
     params.height = 650; 
     params.width = totalWidth; 
     params.y = totalHeght/10; 

     this.getWindow().setAttributes(params); 

可能是它的工作原理......但要确保有关的价值观......

相关问题