相关文章https://blog.csdn.net/weixin_41101173/article/details/80158169
/**
* horizontalScrollView item点击并滑动到中间
* @param horizontalScrollView
* @param itemView
*/
private void performHscrollViewItemClick(HorizontalScrollView horizontalScrollView,View itemView) {
//------get Display's Width--------
DisplayMetrics displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenWidth = displayMetrics.widthPixels;
int scrollX = (itemView.getLeft() - (screenWidth / 2)) + (itemView.getWidth() / 2);
//smooth scrolling horizontalScrollView
horizontalScrollView.smoothScrollTo(scrollX, 0);
//additionally we set current center textView data to our testTextView
// String s = "CenterLocked Item: "+((TextView)view).getText();
// testTextView.setText(s);
}
网友评论