微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

关于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

原文地址:https://www.jb51.cc/xml/297689.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。