Android UI 优化 [ 类别:Layout ]
有一句古话:不论黑猫白猫,能抓到耗子就是好猫。这个也许在某些方面是有道理的,
但对于我们追求精益求精的思想是背道而驰的,往往就是因为满足于一个结果,而放弃探
求更加优化的处理方法。
当关注应用程序或者游戏所达到的结果时,往往非常容易忽视一些优化的问题,例如
内存优化,线程优化,Media 优化和 UI 优化等等。不同的模块都存在更为巧妙的方式来对
待一般性问题,所以每当我们实现一个行为后,稍微多花一些时间来考虑目前所作的工作
是否存在更为高效的解决办法。
这一次我们对常用的 UI Layout 优化说起。在 Android 中最常用 LinearLayout 表示 UI
的框架,而且也是最直观和方便的方法。例如创建一个 UI 用于展现 Item 的基本内容。如
图所示:
直接可以通过 LinearLayout 快速的实现这个 UI 的排列:
View Code XML
<LinearLayout xmlns:
android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/
listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="6dip"
android:src="@drawable/icon" />
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
评论0
最新资源