我只知道這是簡單,大約30分鐘的時間,我會恨我自己......定位與頂視圖表示爲顯示高度的百分比
我有一個由靜態圖像的啓動畫面填滿屏幕。所以我簡單地設置了我在佈局中使用的任何根視圖的背景屬性。
圖像有一個空白區域,我需要放置一個「我接受」按鈕。要處理不同的解決方案,我必須使用顯示高度的百分比來定位 - 58%是現場。
我不能使用layout_weight,因爲這樣會調整button和absolutelayout(在代碼中設置y位置)的大小。
我該如何做到這一點?我不在乎哪個視圖組是父視圖,我對填充空間的「空白」視圖沒有問題。
我的目標在佈局XML完全這樣做是爲了保持我的代碼清潔...
謝謝!
我認爲西蒙關注的是應用'layout_weight'其高度的'Button'本身會迫使尺寸屏幕的42%。按照您的建議將權重應用於'LinearLayout'顯然可以防止這種情況發生,並允許'Button'採用其'自然'大小。 – Squonk 2012-04-13 16:00:30
謝謝傑森。正如預期的那樣,一個「doh」時刻:)這是一個冠軍...... – Simon 2012-04-14 06:49:05