0
我想在我的應用程序集圖片瀏覽的高度和寬度在網格視圖
我使用網格視圖來顯示圖像來創建一個圖片庫,但圖像來顯示搞砸
我怎麼可以顯示圖像平等的嗎?如其他圖像庫應用
佈局文件:
<GridView
android:id="@+id/galleryGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3"
android:rowCount="3"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp" />
Java文件:
public class GalleryManager extends BaseAdapter {
Context context;
List<Drawable> list;
public GalleryManager(Context context , List<Drawable> list) {
this.context = context;
//this.list = list;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
try {
ImageView imageView = new ImageView(context);
imageView.setImageDrawable(list.get(position));
imageView.setScaleType(ImageView.ScaleType.CENTER);
return imageView;
}
catch(Exception e){
Log.i("Tag", "getView: "+e.toString());
}
return null;
}
}
得到這個錯誤:這個自定義視圖應該擴展android.support.v7.widget.app CompatImageView ... – lasthope
我更新我的答案 –