Dlaczego nie po prostu sprawdzić położenie elementu w stosunku do wielkości swojej listy:
padding:
public View getView(int position, View convertView, ViewGroup parent)
{
//recycle views and whatever else you normally would do goes here..
//...
//...
if (position == 0){
convertView.setPadding(0, 10, 0, 0); //padding on top for top item
}
else if (position == getCount() - 1){
convertView.setPadding(0, 0, 0, 10); //padding on bottom for bottom item
}
else{
convertView.setPadding(0, 0, 0, 0); //no padding
}
}
marginesów użytku
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
convertView.setLayoutParams(lp);
Ex :
public View getView(int position, View convertView, ViewGroup parent)
{
//recycle views and whatever else you normally would do goes here..
//...
//...
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
if (position == 0){
lp.setMargins(0, 10, 0, 0); //margin on top for top item
}
else if (position == getCount() - 1){
lp.setMargins(0, 10, 0, 10); //margin on bottom for bottom item
}
else{
lp.setMargins(0, 0, 0, 0); //no margin
}
convertView.setLayoutParams(lp);
}
To jest pod warunkiem, że prawidłowo zaimplementowano metodę getCount() dla karty.
Nasty sugestię, ale jak o górnej/dolnej wyściółki w pierwszym/ostatnim zdaniem sprzęcie? Będziesz musiał sprawdzić i ustawić go we wszystkich widokach w 'getView' ... – Knickedi