關於xml佈局中Fragment與 FrameLayout的理解

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".ActionTab_Activity" >

    <!-- 一定要tool:comtext -->
    <!--如果是fragment,一定要設置某fragment名字
   如 android:name="com.cohere.fc.FragmentProcess" 
    表示啓動時先加載某fragment
    -->


    <Fragment
        android:id="@+id/main_titles"
        android:name="com.cohere.fc.FragmentProcess" 
        android:layout_width="0px"
        android:layout_height="match_parent"
        android:layout_weight="1" />

<pre name="code" class="html">    <!-- FrameLayout是一個放置Fragment的容器 ,
不需要指定某個Fragment的名字,
可以通過FragmentManager動態添加刪除想放入其中的Fragment-->
<FrameLayout android:id="@+id/main_details" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight="4" /></LinearLayout>


FrameLayout與Fragment標籤都是用來放Fragment的,區別是,Fragment標籤只能設置固定的Fragment,而FrameLayout中可以通過FragmentManager更換Fragment

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章