`
cenphoenix
  • 浏览: 160553 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

RelativeLayout

阅读更多

RelativeLayout顾名思义就是根据各个控件之间的关系进行布局

和容器间的关系:
android:layout_alignParentTop

says the widget's top should align with the top of the container


android:layout_alignParentBottom

says the widget's bottom should align with the bottom of the container


android:layout_alignParentLeft

says the widget's left side should align with the left side of the container


android:layout_alignParentRight

 says the widget's right side should align with the right side of the container


android:layout_centerHorizontal

says the widget should be positioned horizontally at the center of the container


android:layout_centerVertical

says the widget should be positioned vertically at the center of the container


android:layout_centerInParent

says the widget should be positioned both horizontally and vertically at the center of the container

 

以上各个属性的值都为boolean值类型

当你需要引用另外一个控件的属性值时,可通过@id/widget_a.property进行引用

 

和其他控件间的关系:

android:layout_above

indicates that the widget should be placed above the widget referenced in the property


android:layout_below

indicates that the widget should be placed below the widget referenced in the property


android:layout_toLeft

indicates that the widget should be placed to the left of the widget referenced in the property


android:layout_toRight

 indicates that the widget should be placed to the right of the widget referenced in the property

 

android:layout_alignTop

 indicates that the widget's top should be aligned with the top of the widget referenced in the property


android:layout_alignBottom

indicates that the widget's bottom should be aligned with the bottom of the widget referenced in the
property


android:layout_alignLeft

indicates that the widget's left should be aligned with the left of the widget referenced in the property


android:layout_alignRight

 indicates that the widget's right should be aligned with the right of the widget referenced in the property


android:layout_alignBaseline

indicates that the baselines of the two widgets should be aligned

 

假如我们需要将控件B放在控件A的右边,我们可以这样进行设置

在控件B上写上:android:layout_toRight ="@id/widget_a"

分享到:
评论

相关推荐

    自定义RelativeLayout圆角图片背景

    在本教程中,我们将深入探讨如何自定义一个`RelativeLayout`,使其具备圆角图片背景的功能。这涉及到自定义属性、设置圆角以及将这些属性应用到布局中。 首先,为了实现自定义`RelativeLayout`,我们需要创建一个新...

    相对布局之RelativeLayout

    在Android应用开发中,`RelativeLayout`是Android布局体系中非常重要的一种布局方式,它以其灵活性和强大的定位能力受到开发者们的喜爱,特别是在游戏开发、相机应用以及增强现实(AR)项目中,`RelativeLayout`更是...

    RelativeLayout相对布局属性

    ### RelativeLayout相对布局属性详解 在Android开发中,`RelativeLayout`是一种非常常见的布局方式,它允许开发者根据父容器或兄弟视图来定义子视图的位置。本文将详细介绍`RelativeLayout`的各种属性及其使用方法...

    android实现自定义RelativeLayout可拖动、缩放、旋转TextView

    本文将深入探讨如何在Android中实现一个自定义的RelativeLayout,使其能够支持TextView的拖动、缩放和旋转功能。 首先,我们需要创建一个新的自定义布局类,继承自RelativeLayout。在这个类中,我们将重写一些关键...

    RelativeLayout布局入门实例

    本教程将聚焦于两种常见的布局管理器:LinearLayout和RelativeLayout,它们都是Android SDK中的基础组件,用于组织和定位UI元素。我们将会深入理解这两种布局的工作原理,并通过一个名为"MyInfo2"的实例来探讨它们的...

    android_relativeLayout_demo

    在Android开发中,布局管理器是构建用户界面的关键部分,其中`RelativeLayout`是常见的布局之一。`RelativeLayout`允许开发者以相对的方式安排各个视图(View)元素,这意味着一个视图的位置可以相对于另一个视图,...

    Android 相对布局 RelativeLayout 属性

    其中,`RelativeLayout`是一种非常灵活的布局方式,它允许子视图根据其他视图的位置或者相对于其父容器的位置进行定位。通过使用一系列属性,开发者可以轻松地控制各个控件的排列方式,从而创造出复杂且美观的界面...

    Android RelativeLayout 的应用

    ### Android RelativeLayout 的应用 在Android开发中,布局是构建用户界面的基础部分。`RelativeLayout`作为常用的布局之一,提供了相对于其他视图或父容器定位视图的能力。本文将深入探讨`RelativeLayout`的关键...

    android LinearLayout与RelativeLayout混用

    LinearLayout和RelativeLayout是两种常见的布局管理器,它们各有特点,能够满足不同的设计需求。当这两种布局需要在同一个界面中混合使用时,可以实现更复杂、灵活的界面效果。下面我们将详细探讨LinearLayout与...

    ScrollView实现自定义RelativeLayout跟随手势上下滑动显示隐藏

    本示例中,我们将探讨如何实现一个特定的功能,即让一个自定义的RelativeLayout根据用户的手势上下滑动来显示或隐藏顶部标题栏。这在很多应用中都非常实用,比如模仿常见的抽屉式导航菜单效果。 首先,我们需要了解...

    Android应用源码之12.RelativeLayout.zip

    在Android应用开发中,RelativeLayout是一种常用的布局管理器,它允许我们根据相对位置来安排View组件。这个"Android应用源码之12.RelativeLayout.zip"压缩包很可能是为了教学或研究目的,提供了一个使用...

    界面布局之相对布局RelativeLayout(代码)

    相对布局(RelativeLayout)是Android SDK提供的一种布局方式,它允许视图组件相对于其他组件或布局的边缘进行定位,从而实现灵活的界面设计。在本教程中,我们将深入探讨相对布局及其在代码中的实现。 首先,相对...

    动态控制RelativeLayout的组件

    在Android开发中,`RelativeLayout`是一种常用的布局管理器,它允许开发者通过相对位置来安排UI组件,而不是基于绝对坐标。这种布局方式对于创建复杂且适应性强的用户界面非常有用。本篇文章将深入探讨如何在运行时...

    Android相对布局RelativeLayout的基本用法

    在Android开发中,布局管理器是构建用户界面的关键组件,其中`RelativeLayout`是最常用和灵活的布局之一。本文将深入探讨`RelativeLayout`的基本用法,包括它的特点、优点以及如何在XML布局文件中配置和使用它。 `...

    仿ios自带滑动删除的relativelayout

    这个“仿ios自带滑动删除的relativelayout”就是一个这样的实现,它允许用户通过在条目上滑动来显示一个删除按钮,从而可以方便地删除项目。 首先,我们要理解`RelativeLayout`在Android中的角色。`RelativeLayout`...

    android布局属性RelativeLayout详解.

    Android 布局属性 RelativeLayout 详解 Android 布局属性 RelativeLayout 是 Android 中常用的布局方式之一,通过它可以实现复杂的界面布局。下面是 RelativeLayout 的主要属性详解: 第一类:属性值为 true 或 ...

    Android-DragView可拖拽的view继承自RelativeLayout

    "Android-DragView可拖拽的view继承自RelativeLayout"是一个专为实现拖拽功能而设计的自定义视图类,它扩展了Android原生的RelativeLayout,使得用户可以自由地在屏幕上拖动视图元素。这一特性在许多应用中都有广泛...

    LinearLayout和RelativeLayout实现精确布局-简单版

    LinearLayout和RelativeLayout是两种最常见的布局类型,它们各有特点,适用于不同的设计需求。本篇文章将探讨如何利用这两种布局实现精确的UI设计,特别是针对简单版的应用评价场景。 首先,我们来了解LinearLayout...

    Android中使用RelativeLayout布局完成的登录界面教学案例任务说明.pdf

    在Android应用开发中,界面设计是至关重要的一步,而`RelativeLayout`是Android提供的一种布局管理器,它允许我们在界面上创建复杂且灵活的布局结构。本篇教学案例旨在指导学生如何利用`RelativeLayout`来实现一个...

Global site tag (gtag.js) - Google Analytics