• 常用布局参考


      1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      2     android:layout_width="match_parent"
      3     android:layout_height="match_parent"
      4     android:orientation="vertical"
      5     >
      6     <ScrollView 
      7         android:layout_weight="4"
      8         android:layout_width="fill_parent"
      9         android:layout_height="wrap_content"
     10         android:layout_marginTop="5dp"
     11         android:layout_marginBottom="5dp"
     12         android:scrollbars="vertical">
     13         <LinearLayout 
     14             android:layout_width="fill_parent"
     15             android:layout_height="wrap_content"
     16             android:orientation="vertical">
     17             <LinearLayout
     18                 android:layout_width="fill_parent"
     19                 android:layout_height="wrap_content"
     20                 android:orientation="horizontal"
     21                 android:layout_marginLeft="10dp"
     22                 android:layout_marginRight="10dp">
     23              
     24                 <ImageButton 
     25                      android:id="@+id/btn_img"
     26                      android:layout_width="60px"
     27                      android:layout_height="60px"
     28                      android:src="@drawable/icon"
     29                     />
     30                 <EditText 
     31                     android:id="@+id/et_name"
     32                     android:layout_width="fill_parent"
     33                     android:layout_height="wrap_content"
     34                     android:gravity="top"
     35                     android:layout_gravity="center_vertical"
     36                     android:hint="姓名"
     37                     />
     38              </LinearLayout> 
     39              <LinearLayout 
     40                  android:layout_width="fill_parent"
     41                  android:layout_height="wrap_content"
     42                  android:orientation="vertical"
     43                  android:layout_marginLeft="10dp"
     44                  android:layout_marginRight="10dp"
     45                  >
     46                  <TextView 
     47                      android:layout_width="match_parent"
     48                      android:layout_height="wrap_content"
     49                      android:text="手机"
     50                      android:textSize="20dp"
     51                      />
     52                  <EditText 
     53                      android:id="@+id/et_mobilephone"
     54                      android:layout_width="fill_parent"
     55                      android:layout_height="wrap_content"
     56                      android:gravity="top"
     57                      android:hint="手机"
     58                      android:phoneNumber="true"
     59                      />
     60              </LinearLayout>
     61              <LinearLayout 
     62                  android:layout_width="fill_parent"
     63                  android:layout_height="wrap_content"
     64                  android:orientation="vertical"
     65                  android:layout_marginLeft="10dp"
     66                  android:layout_marginRight="10dp"
     67                  >
     68                  <TextView 
     69                      android:layout_width="match_parent"
     70                      android:layout_height="wrap_content"
     71                      android:text="办公司电话"
     72                      android:textSize="20dp"
     73                      />
     74                  <EditText 
     75                      android:id="@+id/et_officephone"
     76                      android:layout_width="fill_parent"
     77                      android:layout_height="wrap_content"
     78                      android:gravity="top"
     79                      android:hint="办公司电话"
     80                      android:phoneNumber="true"
     81                      />
     82              </LinearLayout>
     83              <LinearLayout 
     84                  android:layout_width="fill_parent"
     85                  android:layout_height="wrap_content"
     86                  android:orientation="vertical"
     87                  android:layout_marginLeft="10dp"
     88                  android:layout_marginRight="10dp"
     89                  >
     90                  <TextView 
     91                      android:layout_width="match_parent"
     92                      android:layout_height="wrap_content"
     93                      android:text="家庭电话"
     94                      android:textSize="20dp"
     95                      />
     96                  <EditText 
     97                      android:id="@+id/et_homephone"
     98                      android:layout_width="fill_parent"
     99                      android:layout_height="wrap_content"
    100                      android:gravity="top"
    101                      android:hint="家庭电话"
    102                      android:phoneNumber="true"
    103                      />
    104              </LinearLayout>
    105              <LinearLayout 
    106                  android:layout_width="fill_parent"
    107                  android:layout_height="wrap_content"
    108                  android:orientation="vertical"
    109                  android:layout_marginLeft="10dp"
    110                  android:layout_marginRight="10dp"
    111                  >
    112                  <TextView 
    113                      android:layout_width="match_parent"
    114                      android:layout_height="wrap_content"
    115                      android:text="职务职称"
    116                      android:textSize="20dp"
    117                      />
    118                  <EditText 
    119                      android:id="@+id/et_position"
    120                      android:layout_width="fill_parent"
    121                      android:layout_height="wrap_content"
    122                      android:gravity="top"
    123                      android:hint="职务职称"
    124                      />
    125              </LinearLayout>
    126              <LinearLayout 
    127                  android:layout_width="fill_parent"
    128                  android:layout_height="wrap_content"
    129                  android:orientation="vertical"
    130                  android:layout_marginLeft="10dp"
    131                  android:layout_marginRight="10dp"
    132                  >
    133                  <TextView 
    134                      android:layout_width="match_parent"
    135                      android:layout_height="wrap_content"
    136                      android:text="单位名称"
    137                      android:textSize="20dp"
    138                      />
    139                  <EditText 
    140                      android:id="@+id/et_company"
    141                      android:layout_width="fill_parent"
    142                      android:layout_height="wrap_content"
    143                      android:gravity="top"
    144                      android:hint="单位名称"
    145                      />
    146              </LinearLayout>
    147              <LinearLayout 
    148                  android:layout_width="fill_parent"
    149                  android:layout_height="wrap_content"
    150                  android:orientation="vertical"
    151                  android:layout_marginLeft="10dp"
    152                  android:layout_marginRight="10dp"
    153                  >
    154                  <TextView 
    155                      android:layout_width="match_parent"
    156                      android:layout_height="wrap_content"
    157                      android:text="地址"
    158                      android:textSize="20dp"
    159                      />
    160                  <EditText 
    161                      android:id="@+id/et_address"
    162                      android:layout_width="fill_parent"
    163                      android:layout_height="wrap_content"
    164                      android:gravity="top"
    165                      android:hint="地址"
    166                      />
    167              </LinearLayout>
    168              <LinearLayout 
    169                  android:layout_width="fill_parent"
    170                  android:layout_height="wrap_content"
    171                  android:orientation="vertical"
    172                  android:layout_marginLeft="10dp"
    173                  android:layout_marginRight="10dp"
    174                  >
    175                  <TextView 
    176                      android:layout_width="match_parent"
    177                      android:layout_height="wrap_content"
    178                      android:text="Email"
    179                      android:textSize="20dp"
    180                      />
    181                  <EditText 
    182                      android:id="@+id/et_emai"
    183                      android:layout_width="fill_parent"
    184                      android:layout_height="wrap_content"
    185                      android:gravity="top"
    186                      android:hint="Email"
    187                      />
    188              </LinearLayout>
    189               <LinearLayout 
    190                  android:layout_width="fill_parent"
    191                  android:layout_height="wrap_content"
    192                  android:orientation="vertical"
    193                  android:layout_marginLeft="10dp"
    194                  android:layout_marginRight="10dp"
    195                  >
    196                  <TextView 
    197                      android:layout_width="match_parent"
    198                      android:layout_height="wrap_content"
    199                      android:text="备注"
    200                      android:textSize="20dp"
    201                      />
    202                  <EditText 
    203                      android:id="@+id/et_extra"
    204                      android:layout_width="fill_parent"
    205                      android:layout_height="wrap_content"
    206                      android:gravity="top"
    207                      android:hint="备注"
    208                      />
    209              </LinearLayout>
    210         </LinearLayout>
    211     </ScrollView>
    212     <LinearLayout 
    213         android:layout_weight="1"
    214         android:layout_width="fill_parent"
    215         android:layout_height="wrap_content"
    216         android:orientation="horizontal"
    217         android:layout_marginLeft="10dp"
    218         android:layout_marginRight="10dp"
    219         android:layout_marginBottom="5dp"
    220         >
    221        <Button 
    222            android:id="@+id/btn_save"
    223            android:layout_width="wrap_content"
    224            android:layout_height="wrap_content"
    225            android:textSize="20sp"
    226            android:text="保存"
    227            android:gravity="center_horizontal"
    228            android:layout_weight="1"
    229            /> 
    230        <Button 
    231            android:id="@+id/btn_return"
    232            android:layout_width="wrap_content"
    233            android:layout_height="wrap_content"
    234            android:textSize="20sp"
    235            android:text="返回"
    236            android:gravity="center_horizontal"
    237            android:layout_weight="1"
    238            />       
    239     </LinearLayout>
    240 </LinearLayout>

    效果:

    真机查看时,如果不隐藏掉标题,会呈现下面的效果,按钮被遮挡掉一部分,其实布局代码是没有问题的,切记

  • 相关阅读:
    解析库的使用---页面解析总结
    django--学习笔记 一
    项目(三)--个人博客开发
    算法图解(python3版本)--读后感
    "mysql技术内幕innodb存储引擎"--读书笔记
    通过ftp同步服务器文件:遍历文件夹所有文件(含子文件夹、进度条);简单http同步服务器文件实例
    使用node-webkit(v0.35.5)和innosetup(3.6.1)打包将web程序打包为桌面客户端(安装包)
    .netcore3.1使用ELK日志中心(使用NLog数据传输)
    .netcore3.1使用skywalking8.1.0(docker-compose一键部署)
    asp.net 页面刷新锚点失效问题解决
  • 原文地址:https://www.cnblogs.com/hixin/p/4125840.html
Copyright © 2020-2023  润新知