5
什麼是這樣的代碼的目的:什麼是寬度或高度的負值?
android:layout_height="-2"
或者
android:layout_width="-1"
我應該如何解釋這些值?它們是否與layout_weight屬性相關聯?
感謝
什麼是這樣的代碼的目的:什麼是寬度或高度的負值?
android:layout_height="-2"
或者
android:layout_width="-1"
我應該如何解釋這些值?它們是否與layout_weight屬性相關聯?
感謝
編輯: 我的錯誤,我誤解了這個問題。
負值似乎代表match_parent,wrap_content和fill_parent。
當應用-1或-2時,視圖就像填充match_parent或fill_parent一樣填充屏幕。當應用任何數字-3或更低時,行爲與wrap_content相同。
這些值與layout_weight無關,只是Android中寬度和高度的預定義常量。
因爲它是目前編寫的,您的代碼在Eclipse中爲我生成錯誤。 android:layout_width =「 - 1」無效。爲了我的回答,我假設你的意思是android:layout_width =「 - 1dp」。 – theisenp