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就不要设置这个属性了,要不然显示会比较令人郁闷的. 

  • 相关阅读:
    LinuxCentOS6.5:六、克隆虚拟机
    Redis:一、简介
    LinuxCentOS6.5:五、软件安装
    shiro配置异常org.springframework.beans.factory.BeanInitializationException: The security manager does not implement the WebSecurityManager interface.
    Redis:二、安装
    LinuxCentOS6.5:二、基本命令
    HttpPostedFile hf = c.Request.Files[0]; 报错:索引超出 怎么办?
    sqlserver使用中遇到过的
    glassfish error : A full JDK (not just JRE) is required
    计划
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/2478443.html
Copyright © 2011-2022 走看看