ListView,GridView,Gallery

这三个控件的加载自定义的内容的时候,你要加载三次,但是当你打印的时候,却发现他运行的不止三次,那时因为什么呢?

这是android机制中要计算高的时候出现的一些多次调用

具体的可以去网上查找

解决的方法就是

将控件的

android:layout_width="wrap_content"

android:layout_height="wrap_content"

这连个属性给改为

android:layout_width="fill_parent"

android:layout_height="fill_parent"

这样你可能会说那么我要给他指定高度呢?

很简单,不管你是要自适应呢,还是要给定标准的数据,只需要在控件的外面再添加一个parent即可

然后将

android:layout_width="wrap_content"

android:layout_height="wrap_content"

或者是指定的参数给parent 即可!

特别是层层嵌套的话,更应该这么做了,要不然会出现卡屏的现象哦!

之前我做项目

<ListView>

<GridView></GridView>

</ListView>

使用的是

android:layout_width="wrap_content"

android:layout_height="wrap_content"------->卡的要死

改成

android:layout_width="fill_parent"

android:layout_height="fill_parent"-------->爽歪歪啊爽歪歪!

更多相关文章

  1. android获取控件宽和高
  2. Android笔记---常用控件以及用法
  3. Android(安卓)Material Design 系列之 Toolbar 使用详解
  4. Android(安卓)UI 限定字数 单独一行
  5. Android(安卓)ListView那些事
  6. Android(安卓)TV 开发简介
  7. 安卓开发学习之002 LinearLayout之android:layout_gravity详解
  8. Android入门第二篇之LinearLayout、AbsoluteLayout .
  9. android app内置webview,随android版本升级进程关系的变化

随机推荐

  1. Android(安卓)画图之抗锯齿
  2. 使用navigator.userAgent.toLowerCase()
  3. Android之ContentProvider
  4. 第十七章:android解析JSON
  5. 2011.09.01——— android 透明显示
  6. 各种android应用模仿源码
  7. Android日常小问题收集库
  8. 2011.08.31——— android 监听网络变化
  9. Android Studio修改apk打包生成名称
  10. Android网页浏览器的开发