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

  • 相关阅读:
    近期Android学习II
    近期Android学习
    Java中AQS基本实现原理
    Java中CAS 基本实现原理
    SpringBoot 消息国际化配置
    SpringBoot2.0 配置多数据源
    浅谈Java 线程池原理及使用方式
    Java并发编程之闭锁与栅栏
    Java 8 Stream API实例
    第二阶段考试
  • 原文地址:https://www.cnblogs.com/tuhailin/p/5274548.html
Copyright © 2011-2022 走看看