カスタム アダプターを使用する場合は、bindview メソッドで..各子ビューを取得し、存在する子ビューの合計に応じて増加および減少する乗数を持つ新しいマージン レイアウト パラメーターをビューに与えます。
getCount(); で表示される子の総数を取得できます。
マージン レイアウトをビューグループに適用します。
私の構造がはしごのようなパターンに対応することを除いて、私は同じことをしました。
編集:これらは、アイデアを得るために私のコードからいくつかの壊れたスニペットです。
//This is my custom adapter that extends CursorAdapter
@Override
public void bindView(View view, Context context, final Cursor cursor)
{
final RelativeLayout parent = (RelativeLayout)view.findViewById(R.id.text_wrapper);
//This is a parent view that i assigned as a top parent in my xml defining rows of listview
I am finding it through view of bindview. If i don't do this I'll get NPE.
//this is how you will be setting margins for each view
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) parent
.getLayoutParams();
//here I am getting my relative layouts margin params.
mlp.leftMargin = 50*multiplier; //this will offset your each row. here multiplier can be like 0,1,2,3,2,1,0 giving you a circular view.you might have to write some method to get your desired multiplier value.
バインド ビューは、NotifyDatasetChanged が呼び出されるたびに呼び出され、画面に表示される行ごとに呼び出されます。したがって、表示されている行の循環パターンを取得できます。
}