I'm making an app that uses a listview
that has section headers and content. For each header I want to use an image but the view is setting it's height to the image's and not the value that I set the height at. This is in my adapter:
@Override public View getView(int position, View convertView, ViewGroup parent) {
TextView view = (TextView) super.getView(position, convertView, parent);
view.setTextColor(Color.DKGRAY);
Item item = getItem(position);
if (item.type == Item.SECTION) {
if (position == 0) {
view.setBackgroundResource(R.drawable.myImage);
view.setHeight(400);
view.setMaxHeight(400);
}
else {
//deal with other views
}
}
return view;
}
I'm testing this by just setting the first item in the list as a photo, but as I said, the view isn't using 400px as the height. If I set the height the same way in the else
block and just set the background as a color it works fine. I should note that I want to avoid just scaling the picture manually to fit because eventually I want the view to just show a frame of the full image and add a scrolling effect.