我本是想整理下佈局文件的相關知識(見上一篇日誌)
發現width和layout_width的問題很是糾結
百度上找了半天,竟是胡說八道的。。。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.對於填寫內容是這樣:
### 應該是 “數dip”
@@@應該填 "fill_parent","wrap_content","match_parent" 注意也可填“數dip”
2.字面上看帶layout_的是指跟父控件之間的關係,又如layout_weight按比重佔父控件的地
所以這個容易解釋,但width呢!?難道就感覺級別低?
起初我也猜測是這樣,###和@@@試了添了幾組數
<TextView
android:id="@+id/TextView01"
android:background="#0000ff"
android:width=###
android:layout_width=@@@
android:layout_height="wrap_content"
android:text="111111111111111"
/>
最終的結論是 android:width與android:layout_width並無級別之分
是先後之分(當然不是代碼的先後!)
先 聲明 android:width=“Xdip” (X<屏幕寬度)
後 如果 android:layout_width="wrap_content"(內容>Xdip)、“>Xdip”、“fill_parent” 那麼該越界就越界
如果 android:layout_width="wrap_content"(內容<Xdip)、“<Xdip” 那麼寬度就是Xdip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
同理android:height與android:layout_height也如此