• xml布局中include的使用


    参考:http://blog.csdn.net/harvic880925/article/details/17263275

    include_button1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="anjian1" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按键1"/>
    
    </LinearLayout>

     

    include_button2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="anjian2" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按键2"/>
    
    </LinearLayout>

     activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!" />
        <include
            android:id="@+id/key1"
            layout="@layout/include_button1"></include>
    
        <include
            android:id="@+id/key2"
            layout="@layout/include_button2"></include>
    
    </LinearLayout>

  • 相关阅读:
    个人7天安排
    七天安排
    京东搜索规则
    关于从一个整数数组中求得最大的子整数组和
    结对项目开发--电梯调度
    分析英文文本各个词出现的频率
    关于安卓版的eclipse连接数据库并誓言增删改查
    电梯调度 结对开发项目
    求一个二维数组的最大子数组
    求一堆数组中最大的子数组
  • 原文地址:https://www.cnblogs.com/maogefff/p/7846094.html
Copyright © 2020-2023  润新知