下面列出了android.widget.ListView#setOverScrollMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View rootView = getView();
if (rootView != null) {
ListView listView = rootView.findViewById(android.R.id.list);
if (listView != null) {
listView.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
listView.setDividerHeight(0);
}
}
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ListView listView = view.findViewById(android.R.id.list);
if (listView != null) {
listView.setVerticalScrollBarEnabled(false);
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
}
private void init(Context context, AttributeSet attrs) {
mContext = context;
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IndexableStickyListView);
mBarTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_textColor, getResources().getColor(R.color.default_indexBar_textcolor));
mBarTextSize = a.getDimension(R.styleable.IndexableStickyListView_indexBar_textSize, getResources().getDimension(R.dimen.default_indexBar_textSize));
mBarSelectedTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_selected_textColor, getResources().getColor(R.color.dafault_indexBar_selected_textColor));
mRightOverlayColor = a.getColor(R.styleable.IndexableStickyListView_indexListView_rightOverlayColor, getResources().getColor(R.color.default_indexListView_rightOverlayColor));
mTypeOverlay = a.getInt(R.styleable.IndexableStickyListView_indexListView_type_overlay, 0);
a.recycle();
}
if (mContext instanceof Activity) {
((Activity) mContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
mListView = new ListView(context);
mListView.setVerticalScrollBarEnabled(false);
mListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
mListView.setDivider(null);
addView(mListView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mIndexBar = new IndexBar(context, mBarTextColor, mBarSelectedTextColor, mBarTextSize);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.gravity = Gravity.RIGHT;
params.topMargin = IndexBar.dp2px(context, 16);
params.bottomMargin = params.topMargin;
addView(mIndexBar, params);
if (mTypeOverlay == 1) {
showCenterOverlayView(true);
} else if (mTypeOverlay == 2) {
showRightOverlayView(true, mRightOverlayColor);
}
mSearchLayout = new SearchLayout(context);
LayoutParams paramsLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
addView(mSearchLayout, paramsLayout);
mSearchLayout.setVisibility(GONE);
mListView.setOnItemClickListener(this);
mListView.setOnScrollListener(this);
mIndexBar.setOnIndexSelectedListener(new IndexBar.OnIndexTitleSelectedListener() {
@Override
public void onSelection(int position, String indexTitle) {
if (mStickView != null) {
if (!mStickView.getText().toString().equals(indexTitle)) {
mStickView.setText(indexTitle);
}
if (mStickView.getY() != 0) {
mStickView.setY(0);
}
}
}
});
}