android布局(三)——RelativeLayout
本文主要参考:《疯狂java讲义》
<?xml version="1.0" encoding="utf-8"?>
<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="xueyou.xueyoucto.com.androidviews.MainActivity">
<TextView
android:id="@+id/view01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:width="100dp"
android:height="100dp"
android:background="@color/color1" />
<TextView
android:id="@+id/view02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/view01"
android:layout_alignLeft="@+id/view01"
android:width="100dp"
android:height="100dp"
android:background="@color/color2" />
<TextView
android:id="@+id/view03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/view01"
android:layout_below="@+id/view01"
android:width="100dp"
android:height="100dp"
android:background="@color/color3" />
<TextView
android:id="@+id/view04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/view01"
android:layout_alignTop="@+id/view01"
android:width="100dp"
android:height="100dp"
android:background="@color/color4" />
<TextView
android:id="@+id/view05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/view01"
android:layout_alignTop="@+id/view01"
android:width="100dp"
android:height="100dp"
android:background="@color/color5" />
</RelativeLayout>
运行效果:
转载请注明原文地址: https://ju.6miu.com/read-1295299.html