UI基本组件和几大布局

来源:互联网 发布:qq显示mac在线 没有了 编辑:程序博客网 时间:2024/06/11 10:04

所有界面组件的基类(包括ViewGroup类)。常用属性:

属性名                    描述

android:alpha           透明度:0-1

android:background     背景颜色/背景图像。"@null"表示透明

android:clickable        是否可以激发点击事件:true | false

android:focusable       是否可以获得焦点: true | false

android:id                          组件的唯一标识。格式为:"@+id/name"

android:layout_height    组件在布局容器中的布局高度。任何组件都必须要的。可选值为:

"wrap_content":        使组件根据内容来自适应

"match_parent"或"fill_parent":占满该控件所在容器的所有空间尺寸值: 125dp。

android:layout_width    组件在布局容器中的布局宽度。任何组件都必须要的

android:layout_gravity    组件在布局容器中的对齐方式。默认是left|top  (水平|垂直)

android:gravity         组件内部的内容的对齐方式。

android:layout_margin    组件在布局容器中的外边距。

android:padding        上下左右的内边距

android:visibility        是否可见:visible(可见)默认值、invisible(不可见占用空间)、gone(不可见不占用空间)


UI基本组件主要有

FrameLayout—帧布局

         •所有添加到这个布局中的视图都以层叠的方式显示。第一个添加的组

件放到最底层,最后添加的组件显示在最上面,把下一层组件部份或

全部覆盖。

•FrameLayout的大小以子组件(可见)最大项的大小来计算

•保证所有子组件正确呈现:android:measureAllChildren=“true”

         <?xmlversion="1.0"encoding="utf-8"?>

<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="match_parent"

   android:layout_height="match_parent">

 

    <TextViewandroid:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="@string/framelayout_title"

        android:textSize="18sp"

        android:textStyle="bold"

        android:textColor="#536D86"

        android:background="@drawable/bar_bg"

        android:gravity="center"/>

   

    <ImageViewandroid:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/btn_edit"

        android:contentDescription="@string/blank"

        android:layout_gravity="left|top"/>

   

    <ImageViewandroid:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/btn_refresh"

        android:contentDescription="@string/blank"

        android:layout_gravity="right|top"/>

 

</FrameLayout>

 


0 0