2010-12-15 24 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); 

可能是它的工作原理......但要確保有關的價值觀......

相關問題