In the gallery tutorial they create a new ImageView in code and apply Gallery.LayoutParams. I use a gallery with a custom adapter and want to inflate a imageview from xml and use that as the gallery item. The problem is, that the given size (see item xml definition underneath) is disregarded.
Custom Adapter:
public View getView(final int position, View convertView,
final ViewGroup parent) {
ViewHolder holder;
if(convertView == null) {
convertView = m_inflater.inflate(R.layout.coverflow_item, null);
holder = new ViewHolder();
holder.coverImage = (ImageView)convertView;
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
m_imageCache.download(m_imageUrls.get(position), holder.coverImage);
return convertView;
}
Item xml:
<?xml version="1.0" encoding="UTF-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleType="centerInside"/>
Is there a way to apply the Gallery.LayoutParams in the xml?
PS: I know that i could apply the Gallery.LayoutParams in code, but this is only a simplefied case ... the gallery item in my case is a bit more complex and that is the reason why i want to do it in the xml.