android ImageView设置属性layout_height="fill_parent"后,控件高度与图片高度不一致的问题
Posted on 2011-07-18 10:42 codingX 阅读(2260) 评论(0) 收藏 举报xml代码
1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical" android:layout_width="fill_parent"
4 android:layout_height="fill_parent">
5 <GridView android:id="@+id/gride" android:layout_width="fill_parent"
6 android:layout_height="fill_parent" android:numColumns="3"
7 android:verticalSpacing="5dip" />
8 </LinearLayout>
java代码
ImageView iv = new ImageView(activity);
iv.setAdjustViewBounds(true); //必须设置这个属性才能保证控件高度与图片高度一直
iv.setImageResource(image[position]);
浙公网安备 33010602011771号