ListView,GridView,Galleryandroid
这三个控件的加载自定义的内容的时候,你要加载三次,可是当你打印的时候,却发现他运行的不止三次,那时由于什么呢?List
这是android机制中要计算高的时候出现的一些屡次调用自适应
具体的能够去网上查找方法
解决的方法就是layout
将控件的数据
android:layout_width="wrap_content"项目
android:layout_height="wrap_content"co
这连个属性给改成参数
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"-------->爽歪歪啊爽歪歪!