android 布局

来源:互联网 发布:中国证券网软件下载 编辑:程序博客网 时间:2024/05/17 08:40

android 线性布局,相对布局,单帧布局,绝对布局

RelativeLayout 里常用的位置属性如下:

android:layout_toLeftOf —— 该组件位于引用组件的左方
    android:layout_toRightOf —— 该组件位于引用组件的右方
    android:layout_above —— 该组件位于引用组件的上方
    android:layout_below —— 该组件位于引用组件的下方

???    android:layout_alignParentLeft —— 该组件是否对齐父组件的左端
???    android:layout_alignParentRight —— 该组件是否齐其父组件的右端
???    android:layout_alignParentTop —— 该组件是否对齐父组件的顶部
???    android:layout_alignParentBottom —— 该组件是否对齐父组件的底部

    android:layout_centerInParent —— 该组件是否相对于父组件居中
    android:layout_centerHorizontal —— 该组件是否横向居中
    android:layout_centerVertical —— 该组件是否垂直居中



代码如下:

<?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="com.example.scxh.a1.A1">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/textView1"        android:text="文本框1"        android:textSize="48dp"        android:layout_centerInParent="true"        />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/textView2"        android:text="文本框2"        android:textSize="48dp"        android:layout_above        />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/textView3"        android:text="文本框3"        android:textSize="48dp"        android:layout_centerInParent        android:layout_alignParentTop="true"        android:layout_alignParentRight="true"        android:layout_alignParentEnd="true" />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/textView4"        android:text="文本框4"        android:textSize="48dp"        android:layout_alignParentBottom="true"        />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/textView5"        android:text="文本框5"        android:textSize="48dp"        android:layout_alignParentRight="true"        android:layout_alignParentBottom="true"        /></RelativeLayout>


Framelayout 单帧布局:

所以的元素都放在左顶,后一个元素会部分或者全部覆盖





0 0
原创粉丝点击