zoukankan      html  css  js  c++  java
  • Android开发(三) android布局

      这一节我们讲解一下android的UI布局。和我们制作网页一样,也需要为我们手机上的控件进行一下布局,android系统中提供了很多灵活的布局类,比如LinearLayout、RelativeLayout、FrameLayout等等,这里我们简单的介绍一下这三个布局:

      1、RelativeLayout,从字面上可以看出这个是相对布局类。也就是说在这个布局里面的控件的位置都是通过相对位置来计算的。

    RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <TextView
    android:id="@+id/login_name"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:layout_marginTop
    ="8dip"
    android:text
    ="User Name:"
    />
    <EditText
    android:id="@+id/txtLoginName"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="wrap_content"
    android:layout_toRightOf
    ="@id/login_name"
    android:layout_alignTop
    ="@id/login_name"
    android:layout_marginLeft
    ="40dip"
    android:layout_marginTop
    ="-8dip"
    android:inputType
    ="text"
    />
    <TextView
    android:id="@+id/password"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:layout_below
    ="@id/login_name"
    android:layout_marginTop
    ="80dip"
    android:text
    ="Password:"
    />
    <EditText
    android:id="@+id/txtPwd"
    android:layout_width
    ="fill_parent"
    android:layout_height
    ="wrap_content"
    android:layout_toRightOf
    ="@id/password"
    android:layout_alignTop
    ="@id/password"
    android:layout_marginLeft
    ="40dip"
    android:layout_marginTop
    ="-8dip"
    android:inputType
    ="text"
    />
    <Button
    android:id="@+id/btnLogin"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:layout_below
    ="@id/password"
    android:layout_marginTop
    ="50dip"
    android:layout_marginLeft
    ="30dip"
    android:text
    ="Login"
    />
    <Button
    android:id="@+id/btnCancel"
    android:layout_width
    ="wrap_content"
    android:layout_height
    ="wrap_content"
    android:layout_toRightOf
    ="@id/btnLogin"
    android:layout_alignTop
    ="@id/btnLogin"
    android:layout_marginTop
    ="0dip"
    android:layout_marginLeft
    ="30dip"
    android:text
    ="Cancel"
    />
    </RelativeLayout>

    上面代码显示的布局是这样的:



  • 相关阅读:
    一个网卡绑定多个IP和多个网卡用一个ip的设置
    Linux操纵细碎以太网卡的装配及设置2
    教你若何制作软盘版的 Linux系统防火墙
    Ubuntu Linux体系中装置GNOME初步劈脸菜单
    构筑Linux防火墙之集团用户设置防火墙1
    Linux系统Iptables端方执行按次过细讲解
    Proxy源代码分析 谈Linux收集编程身手
    Linux使用系统以太网卡的安装及设置装备陈设1
    操持Linux下Oracle Tomcat 8080端口争持2
    Linux操作体系上差别文件体系的兼容成就
  • 原文地址:https://www.cnblogs.com/bugY/p/2396653.html
Copyright © 2011-2022 走看看