Reputation: 9135
I am trying to make the height of the first row of my listView taller than the remaining. I am able to a apply a different layout for row 1, but I cannot make the height different. I am using a custom adapter...here is my getView that chooses the appropriate row layout:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int theType = getItemViewType(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (theType == 0) {
convertView = inflater.inflate(R.layout.location_list_row_one, null);
ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
imagView.setBackground(R.drawable.image);
TextView name = (TextView) convertView.findViewById(R.id.name);
name.setText("Name");
} else if (theType == 1) {
convertView = inflater.inflate(R.layout.location_list_row_two, null);
ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
imagView.setBackground(R.drawable.image);
TextView name = (TextView) convertView.findViewById(R.id.name);
name.setText("Name");
}
}
return convertView;
}
My row layouts are wrapped in a Relative layout, so I need to make the RL height taller in row one. Any ideas?
Upvotes: 0
Views: 69
Reputation: 1123
You can use a different layout and add as headerview to listview.
Upvotes: 1
Reputation: 1430
You can try with padding
:
convertView.setPadding(left, right, top, bottom);
Upvotes: 0