zoukankan      html  css  js  c++  java
  • Android入门第二篇之LinearLayout、AbsoluteLayout

      Android 的UI 布局都以Layout 作为容器,在上面按照规定排列控件,这方面跟JAVA 的Swing 和LWUIT 很像。控件跟Layout 有很多属性是一样的,可以在Properties 里面修改,跟.NET/Delphi 等RAD 类似,其中最常用的属性有以下这些:

    id="@+id/edtInput",ID 是连接UI 与代码的桥梁

    Gravity= "center" ,Layout 中的控件居中

    1

    layout_width="fill_parent" ,自动填充至屏幕宽度,layout_height 同理
    2

    layout_width="wrap_content" ,自动填充为控件大小,layout_height 同理
    3

          LinearLayout ,在入门第一篇所用的Layout 就是LinearLayout ,它的理解很简单:在LinearLayout 里面的控件,按照水平或者垂直排列:
    orientation="horizontal" :水平排列;orientation=" vertical" :垂直排列
    当LinearLayout 是horizontal ,并且里面的控件使用了layout_width="fill_parent" ,第二组控件会挡在屏幕的右边,那也就是看不到了。。。

          AbsoluteLayout ,是一个按照绝对坐标定义的布局,由于使用绝对坐标去定位控件,因此要实现自适应界面时,应尽少使用 AbsoluteLayout 。 AbsoluteLayout 里面的控件都以layout_x 、layout_y 来定义其位置:
    4

    上图中的TextView01的X坐标为10px,Y坐标为10px:

    1. <AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_height="wrap_content" android:layout_width="fill_parent" >    
    2. <TextView android:text="TextView01" android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_y="10px" android:layout_width="wrap_content" android:layout_x="110px">    
    3. </TextView>    
    4. </AbsoluteLayout>  

  • 相关阅读:
    BZOJ3073 Journeys
    UOJ261 【NOIP2016】天天爱跑步 LCA+动态开点线段树
    [bzoj2654] tree 最小生成树kruskal+二分
    【ZJOI2007】【BZOJ1059】矩阵游戏 匈牙利算法
    [Bzoj 2427] [HAOI2010] 软件安装 tarjan缩点+树形DP
    [CQOI2011]放棋子--DP
    BZOJ 3990 排序
    (六)接入层:反向代理,接入层扩容,负载均衡
    (五)伪分布式:你以为,多机就是分布式?
    (四)容量设计:流量高低,对架构究竟有什么影响?
  • 原文地址:https://www.cnblogs.com/xyzlmn/p/3168345.html
Copyright © 2011-2022 走看看