2019独角兽企业重金招聘Python工程师标准>>>

这样的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
   
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/hello" />
   
    <LinearLayout android:id="@+id/layout1"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        android:orientation="vertical"
        android:background="#00FF22"
        android:layout_weight="1">
        <TextView
               android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
    </LinearLayout>
       
   <LinearLayout android:id="@+id/layout2"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        android:orientation="vertical"
        android:background="#FF9900"
        android:layout_weight="1">
        <TextView
               android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
   </LinearLayout>
       
    <LinearLayout android:id="@+id/layout3"
        android:layout_width = "fill_parent"
        android:layout_height = "wrap_content"
        android:orientation="vertical"
        android:background="#FFFFFF"
        android:layout_weight="1">
        <TextView
               android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
   </LinearLayout>
</LinearLayout>

还是下边的布局更容易维护:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
   
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="@string/hello" />
   
    <include android:id="@+id/layout1" layout="@layout/layout_item" />
    <include android:id="@+id/layout2" layout="@layout/layout_item" />
    <include android:id="@+id/layout3" layout="@layout/layout_item" />
   
</LinearLayout>

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_item" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:orientation="vertical"
    android:background="#FF0000" android:layout_weight="1">
    <TextView android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>

下边方式与上边的区别就是需要在代码中去修改一些UI组件的属性,其实带来的复杂性并不大并且可维护性上要好很多。以上只是抛砖引玉,Partner作为一个有工作经验的人竟然想不到...

转载于:https://my.oschina.net/kingguary/blog/38026

记得重用layout相关推荐

  1. Android layout 优化:使用include和merge 标签

    使用<include /> 标签来重用layout代码 如果在一个项目中需要用到相同的布局设计,可以通过<include /> 标签来重用layout代码,该标签在androi ...

  2. Unity/Auto Layout -- 理解Layout Elements(布局元素)

    前言 在UGUI1中,Canvas下的每个GameObject都会自动添加 Rect Transform 组件来控制自身的位置和大小.通常情况下,基于Rect Transform的布局系统已经足够灵活 ...

  3. Andorid-15k+的面试题。

    andorid开发也做了3年有余了,也面试很多加企业,借此机会分享一下,我们中遇到过的问题以及解决方案吧,希望能够对正在找工作的andoird程序员有一定的帮助. 特别献上整理过的50道面试题目 1. ...

  4. BAT等公司高薪招聘Android开发面试题目集锦

    整理过的50道面试题目 1.listView的优化方式 重用convertView viewHolder static class viewHolder 在列表里面有图片的情况下,监听滑动不加载图片 ...

  5. App性能优化(布局优化,线程优化,app瘦身优化,页面切换优化,App启动优化,内存优化)

    Android APP性能优化(最新总结) 在目前Android开发中,UI布局可以说是每个App使用频率很高的,随着UI越来越多,布局的重复性.复杂度也随之增长,这样使得UI布局的优化,显得至关重要 ...

  6. ym——Andorid-15k+的面试题。

    转载请注明本文出自Cym的博客(http://blog.csdn.net/cym492224103),谢谢支持! 前言 最近才开的博客,希望大家多多关注,andorid开发也做了3年有余了,也面试多家 ...

  7. Andorid-的面试题

    转自:http://blog.csdn.net/cym492224103/article/details/38417927 前言 最近才开的博客,希望大家多多关注,andorid开发也做了3年有余了, ...

  8. androidtest 31

    转载地址尊重原作者:http://blog.csdn.NET/cym492224103/article/details/38417927 最近才开的博客,希望大家多多关注,andorid开发也做了3年 ...

  9. android 15K+面试题

    转载自:http://blog.csdn.net/cym492224103/article/details/38417927 andorid开发也做了3年有余了,也面试很多加企业,借此机会分享一下,我 ...

最新文章

  1. R语言ggplot2可视化设置不同的图像主题(theme):使用各种不同的主题(theme)可视化数据、单的黑白主题theme_bw主题(theme)、默认的主题(theme)可视化数据
  2. c语言电子期末考试题,山东师范大学11-12电子C语言期末试题
  3. C# 使用WinApi操作剪切板Clipboard
  4. django框架学习文档_Python四大主流网络编程框架,你知道么?
  5. 【Groonga】Groonga 简介
  6. jquery ajax实例get,jQuery中ajax的get()方法用法实例
  7. 横向扩展 纵向扩展 数据库_扩展数据库–减少扩展的艺术
  8. Java中的类型列表与类型ArrayList
  9. 计算机考研复试难,艰难与快乐:2008年重庆邮电大学计算机考研复试经历
  10. msdia140.dll 已加载,但对DllRegisterServer 的调用失败, 错误代码: 0x80070005
  11. C++学习(四九二)cmake file的GLOB和GLOB_RECURSE
  12. java登陆界面_【java中实现登录界面功能】
  13. OAuth2.0系列四:OAuth2.0简化模式
  14. 程序员写好简历的五大技巧
  15. BI数据分析师工作说明
  16. NLP学习(二)中文分词技术
  17. android--------Android Studio常见问题以及解决方式
  18. 海南安全员A证怎么考多选题库
  19. 《深入浅出WPF》——XAML语法及基础知识
  20. 全国计算机技术与软件专业技术资格(水平)考试【软件评测师】-考试内容总结(六)程序设计语言知识...

热门文章

  1. Pytorch(7)-自己设计神经网络会遇到的问题
  2. 什么是TTL电平、CMOS电平、RS232电平
  3. 用Python在Tomcat成功启动后自动打开浏览器访问Web应用
  4. cad怎么快速算面积_用cad算面积的快捷键方法步骤详细,大朗CAD培训班
  5. C++内存管理(1)
  6. FFPLAY的原理(一)
  7. Spring事务传播行为7种类型 --- 看一遍就能记住!
  8. Android - AsyncTask你知道多少?
  9. 设计模式--抽象工厂(个人笔记)
  10. 跨站的艺术-XSS Fuzzing 的技巧