我有一个自定义ExpandableScrollView
(与库存无关):
public class ExpandableListView extends ListView
{
public ExpandableListView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
expand();
}
public void expand() {
ListAdapter mAdapter = getAdapter();
int totalHeight = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
View mView = mAdapter.getView(i, null, this);
mView.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
totalHeight += mView.getMeasuredHeight();
}
ViewGroup.LayoutParams params = getLayoutParams();
params.height = totalHeight
+ (getDividerHeight() * (mAdapter.getCount() - 1));
setLayoutParams(params);
requestLayout();
}
}
我在ScrollView
中有一个这个视图的实例。问题是当布局膨胀并附加到窗口时,ScrollView
会滚动到底部。
我试图弄清楚ScrollView
或ExpandableScrollView
是否存在问题。也许我应该在另一个循环中扩展列表?
由于