加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

关于xml布局中Fragment与 FrameLayout的理解

发布时间:2020-12-16 06:37:00 所属栏目:百科 来源:网络整理
导读:?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="ma
<?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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读