首页 > 其他 > 详细

include的使用

时间:2016-03-14 09:28:13      阅读:188      评论:0      收藏:0      [点我收藏+]

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

include的使用

原文:http://www.cnblogs.com/tuhailin/p/5274548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!