zoukankan      html  css  js  c++  java
  • Android引入布局

    假设我们要在main布局中引入标题栏,我们只需要在activity_main布局文件中使用语句:

    <include layout="@layout/title" />
    

    完整布局文件:

    title.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/title_bg">
        <Button
            android:id="@+id/title_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="5dp"
            android:background="@drawable/back_bg"
            android:text="Back"
            android:textColor="#fff"/>
        <TextView
            android:id="@+id/title_text"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Title Text"
            android:textColor="#fff"
            android:textSize="24sp"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_margin="5dp"
            android:background="@drawable/edit_bg"
            android:text="Edit"
            android:textColor="#fff"/>
    
    </LinearLayout>
    

    atcivity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include layout="@layout/title" />
    
    </LinearLayout>
    

    效果:

  • 相关阅读:
    c3p0整合mysql报错问题
    MySQL错误问题
    导入项目@Override报错原因及解决办法
    AtomicInteger线程安全的计数器
    jq实现鼠标经过出现上拉菜单
    css实现文字裁切效果
    echarts地图
    css3实现 鼠标经过li时动态画边框(jq库导航)
    仿妙味课堂导航(转)
    jq仿 妙味课堂导航01
  • 原文地址:https://www.cnblogs.com/fanlumaster/p/13733164.html
Copyright © 2011-2022 走看看