zoukankan      html  css  js  c++  java
  • include的使用

    String.xml文件下设置<String></String>的值如下:

    <string name="text">include的使用</string>    <!-- 在activity_main.xml中使用 -->
    <string name="bottom">版权所有,copy 1999-2013 德升时装公司</string>  <!-- 在bottom.xml中使用 -->

    bottom.xml中的代码如下:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
    android:id="@+id/textview1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/bottom"
    android:textSize="15sp"/>
    </LinearLayout>

    activity_main.xml的代码如下:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="@string/text" />
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:background="#cccccc"
    android:orientation="vertical"
    >

    <include layout="@layout/bottom" android:id="@+id/borrom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
    </LinearLayout>

    </RelativeLayout>

      注:include的使用是为了去优化原始的布局代码,所以在学校include之前先把布局学好

  • 相关阅读:
    Java集合中List,Set以及Map等集合体系详解
    Rabbit-MQ-3 队列的属性和消息的属性
    RabbitMQ-1 基本概念和实现简单生产消费者
    ActiveMQ-3
    日期时间类
    字符串反转
    SpringBoot2.0+Shiro+MyBatisPlus权限管理系统
    Servlet+JSP+JDBC学生选课系统
    SpringMVC+Spring+Hibernate个人家庭财务管理系统
    Servlet中FilterConfig的使用
  • 原文地址:https://www.cnblogs.com/tuhailin/p/5274548.html
Copyright © 2011-2022 走看看