zoukankan      html  css  js  c++  java
  • Android布局学习

    习惯了Delphi/VB等RAD的拖放布局,使用Android的布局管理器还真不习惯.

    例如要实现下面的界面布局: 


    则需要如下设置:

     1 <LinearLayout
     2         android:layout_width="wrap_content"
     3         android:layout_height="wrap_content"
     4         android:orientation="horizontal" >
     5 
     6         <TextView
     7             android:id="@+id/textView1"
     8             android:layout_width="wrap_content"
     9             android:layout_height="wrap_content"
    10             android:text="编码" />
    11 
    12         <EditText
    13             android:id="@+id/editText1"
    14             android:layout_width="match_parent"
    15             android:layout_height="wrap_content"
    16             android:layout_weight="2"
    17             android:ems="10" >
    18 
    19             <requestFocus />
    20         </EditText>
    21         
    22 
    23         <TextView
    24             android:id="@+id/textView2"
    25             android:layout_width="wrap_content"
    26             android:layout_height="wrap_content"
    27             android:text="名称" />
    28         
    29 
    30 
    31 
    32 
    33         <EditText
    34             android:id="@+id/editText2"
    35             android:layout_width="wrap_content"
    36             android:layout_height="wrap_content"
    37             android:layout_weight="1"
    38             android:ems="10" >
    39 
    40             <requestFocus />
    41         </EditText>
    42       

    43     </LinearLayout> 

    这里比较重要的属性是:

    android:layout_weight

    该属性是设置比重的,但设置好像是反的,TextView就不要设置这个属性了,要不然显示会比较令人郁闷的. 

  • 相关阅读:
    POJ-3176 Cow Bowling
    01背包、完全背包、多重背包
    最后的几天暑假学习
    暑假的学习
    凸包算法(Graham扫描法)详解
    微软版的SqlHelper.cs类
    SQL语句分组排序,多表关联排序
    SQL存储过程分页(通用的拼接SQL语句思路实现)
    增加删除字段修改字段名,修改表结构,非常用SQL语句技巧总结
    Asp.net mvc返回Xml结果,扩展Controller实现XmlResult以返回XML格式数据
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/2478443.html
Copyright © 2011-2022 走看看