当我学习片段时
http://developer.android.com/reference/android/app/Fragment.html
我在 layout-land/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>
为什么片段和框架布局的布局宽度都设置为零?我在纵向、设置上尝试了相同的 xml android:orientation="vertical"
,并显示了一个空白屏幕。那么里面有什么秘密呢?我的意思是垂直和水平之间有什么区别?那有什么特别之处FrameLayout
呢?