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之前先把布局学好

  • 相关阅读:
    CF710F String Set Queries(AC自动机+二进制分组)
    P5231 [JSOI2012]玄武密码(AC自动机)
    AC自动机基础&应用
    [SDOI2011]计算器(快速幂,线性同余方程,BSGS)
    数论——欧拉定理和费马小定理
    AtCoder Beginner Contest 173 题解
    【CSP2019】树的重心(树的重心、倍增、换根)
    CF708C Centroids(换根dp,树的重心)
    凸包(Graham与Andrew算法求凸包)
    [USACO10MAR]Great Cow Gathering G(换根dp)
  • 原文地址:https://www.cnblogs.com/tuhailin/p/5274548.html
Copyright © 2011-2022 走看看