如果您将使用自定义适配器,那么在您的 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 时都会调用绑定视图,并且会为屏幕上可见的每一行调用绑定视图。因此,您可以获得可见行的圆形模式。
}