當我學習上爲什麼要將layout_width設置爲ZERO?
http://developer.android.com/reference/android/app/Fragment.html
片段只見佈局土地/ fragment_layout.xml下面的代碼:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
<fragment class="com.example.android.apis.app.FragmentLayout$TitlesFragment"
android:id="@+id/titles" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
<FrameLayout android:id="@+id/details" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent"
android:background="?android:attr/detailsElementBackground" />
</LinearLayout>
爲什麼片段的FrameLayout的layout_width的都設置爲零? ? 我在縱向上嘗試了相同的xml,設置爲android:orientation="vertical"
,並顯示一個空白屏幕。那麼,那裏有什麼祕密?我的意思是縱向和橫向之間有什麼區別?那FrameLayout
的特殊功能是什麼?
祕密是***機器人:layout_weight = 「1」 *** [瞭解更多](http://stackoverflow.com/a/3996104/488434) – 2013-02-24 08:02:10
它是一種修復了某些版本的android版本的bug,如果寬度是wrap_content或fill_parent,ght不會被正確地考慮。出於某種原因,可以在整個屏幕上正確權衡兩者。 – 2013-02-24 08:02:19
@ AhmadAl-Kayyali非常感謝:)我將xml更改爲android:layout_width =「match_parent」android:layout_height =「0px」'當垂直時,它工作! – Flybywind 2013-02-24 08:13:55