Setting up Android gallery to set image size using xml

In the gallery tutorial, they create new ImageView code and use Gallery.LayoutParams. I am using a gallery with a custom adapter and want to inflate an image from xml and use it as a gallery element. The problem is that this size (see xml element definition below) is not taken into account.

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; } 

Xml element:

 <?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 any way to apply Gallery.LayoutParams in xml?

PS: I know that I can apply Gallery.LayoutParams in the code, but this is just a simple case ... the gallery element in my case is a little more complicated, and for this reason I want to do this in xml.

+4
source share
1 answer

after searching for another 2 hours, I finally found the answer: fooobar.com/questions/465589 / ...

+5
source

Source: https://habr.com/ru/post/1332127/


All Articles