<include> tag basically means ‘take that file and paste it’s contents here’
<merge > The layout which we have to use must be enclosed under merge tag, so that we can include layouts from other xmls.
[u][/u]
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/Button11"
android:text="Button11"></Button>
<Button android:layout_below="@id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/Button12" android:text="Button12"></Button>
</LinearLayout>
</merge>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@+id/RelativeLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true">
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Next Activity "></Button>
</RelativeLayout>
<RelativeLayout android:id="@+id/RelativeLayout03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<include layout="@layout/footer" />
</RelativeLayout>
</RelativeLayout>
public class Splash extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.Button01).setOnClickListener(this);
findViewById(R.id.Button11).setOnClickListener(this);
findViewById(R.id.Button12).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.Button01:
startActivity(new Intent(this, Act2.class));
break;
case R.id.Button11:
Toast.makeText(this, "Button 11 - Activity 1 ....",
Toast.LENGTH_SHORT).show();
break;
case R.id.Button12:
Toast.makeText(this, "Button 12 - Activity 1 ....",
Toast.LENGTH_SHORT).show();
break;
}
}
}
You can download its complete source code from here .
http://www.megaupload.com/?d=XZ3KTOGI
分享到:
相关推荐
6. 碎片布局(Fragment Layout):虽然不是直接的布局类型,碎片在Android中用于创建可重用的UI片段,它们可以嵌入到活动中,提供更灵活的界面设计,特别是在平板设备上。 7. CoordinatorLayout:这是一种高级布局...
在Android应用开发中,Fragment是构建用户界面的重要组成部分,它允许开发者在单个活动中创建可重用、可组合的UI块。本主题将深入探讨如何在一个主Layout文件中包含两个Fragment,以及如何实现这样的复合界面。 ...
android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/dialog_background"> android:id="@+id/tvDialogTitle" ...
需要注意的是,`merge`标签必须作为顶级元素,并且不能包含根布局属性(如`android:layout_width`和`android:layout_height`)。此外,由于`merge`标签不会生成实际的View对象,所以它不能直接设置属性,所有属性...
android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> android:id="@+id/listViewComments" android:layout_width=...
Android 应用程序开发中,某些资源文件或 UI 组件可以被重用,以提高开发效率和减少代码冗余。例如,某个按钮的样式可以被定义在一个 XML 文件中,然后在多个活动中重用该按钮。 二、TextView 属性设置 TextView ...
### Android Layout布局分析与优化 #### 一、概述 在Android开发中,高效的布局设计对于提升应用性能至关重要。本文将详细介绍如何使用Hierarchy Viewer工具进行布局分析,并基于分析结果提出优化建议,帮助开发者...
- `android:layout_width` 和 `android:layout_height`:定义视图的宽度和高度,可设置为`match_parent`(填充父容器)、`wrap_content`(根据内容自动调整大小)或具体的像素值。 - `android:orientation`:在`...
`include`和`merge`标签是Android XML布局文件中两个非常重要的元素,它们帮助开发者实现布局的重用和优化,提高代码的可维护性和效率。本篇文章将深入探讨这两个标签的使用方法以及它们在Android开发中的作用。 ##...
例如,`android:text`属性用于设置按钮上的文本,而`android:layout_width`和`android:layout_height`则指定了组件的尺寸。 **为什么使用XML布局?** 1. **代码分离**:XML布局将界面设计与业务逻辑分开,使得代码...
在Android开发中,布局(Layout)是构建用户界面的核心组件,它们决定了屏幕上元素的排列方式和相互关系。本文将深入探讨五种主要的布局控件:线性布局(LinearLayout)、框架布局(FrameLayout)、表格布局...
android:layout_height="match_parent" /> ``` 接着,我们需要创建一个表示列表项的布局文件(如 item_list.xml),例如: ```xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...
- `android:layout_toLeftOf` / `android:layout_toRightOf`:使视图位于另一个视图的左边或右边。 - `android:layout_below` / `android:layout_above`:使视图位于另一个视图的下方或上方。 3. **视图之间的...
在Android开发中,Fragment是应用程序界面的一个可重用组件,它可以在Activity中承载用户界面的各个部分。Fragment的概念引入是为了让开发者能更好地处理大屏幕设备,如平板电脑,同时也可以在手机等小屏幕设备上...
android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> android:id="@android:id/list" android:layout_width="match_parent" android:layout_...
布局(Layout)在Android软件开发上的重要角色”这一主题时,我们首先需要理解布局(Layout)在Android开发环境中的核心地位。布局不仅关乎界面设计的美观,更是连接用户与功能的关键桥梁,其重要性不言而喻。 ### ...
在Android应用开发中,Fragment是Android SDK 3.0(API级别11)引入的一个重要组件,用于构建可重用的、模块化的用户界面部分。TabActivity曾是Android早期版本中实现标签页切换的主要方式,但随着Android API的发展...
在Android应用开发中,Fragment是Android SDK提供的一种组件,它允许开发者在Activity中创建可重用的UI块。Fragment的设计使得应用程序能更好地适应不同屏幕尺寸和配置,如手机和平板。"Android Fragment的简单使用...
android:layout_width="match_parent" android:layout_height="match_parent" /> ``` 接着,为了提供`ViewPager`需要的数据源,我们需要创建一个`FragmentPagerAdapter`或`FragmentStatePagerAdapter`的子类。这...
android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> android:id="@+id/radio_option1" android:layout_width="wrap_content" android:layout_...