Android studio 新建一个项目,修改XML如下:
项目Activity名称为:MyRelativeLayout
<?xml version="1.0" encoding="utf-8"?><!--相对布局的使用-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MyRelativeLayout">
<!--orientation:方向-->
<!--match_parent:与父类向适应-->
<!--layout_centerInParent:父类的中间-->
<!-- 给控件定义以个id -->
<!-- wrap_content:包装所容纳的内容-->
<!-- 本例程使用id相对位置实现位置排布-->
<!--线性布局嵌套相对布局-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/mena"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Mema" />
<Button
android:id="@+id/above"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/mena"
android:layout_centerInParent="true"
android:text="↑" />
<Button
android:id

最低0.47元/天 解锁文章
2989

被折叠的 条评论
为什么被折叠?



