我正在做的应用程序,我必须让我的半屏幕可见,半屏幕沉闷。当我开始滚动时,First View应该是清晰的,否则就是Hazy Manner。一旦我滚动它们并且第一个位置从屏幕上消失第二个位置项必须清除,而其他在Hazy中意味着沉闷。我能怎么做 ? 我尝试了什么......
我的适配器
@Override
public void onBindViewHolder(PageCircleIndiAdapter.ViewHolder holder, int position) {
final PageModels pageModels = pageList.get(position);
if (pageList.get(position) != null) {
holder.imageView.setImageResource(pageModels.resourceId);
if (position == 0) {
holder.imageView.setAlpha(1f);
} else if (position == pageList.size() - 1) {
holder.imageView.setAlpha(1f);
pageCircleIndicator.changeIndicator(position);
} else if (position > firstVisible && position < lastVisible) {
pageCircleIndicator.changeIndicator(position);
holder.imageView.setAlpha(0.2f);
}
if (position == pageList.size() - 1) {
pageCircleIndicator.changeIndicator(position);
} else {
holder.imageView.setAlpha(0.2f);
pageCircleIndicator.changeIndicator(position);
}
}
}
我在MainActivity上的ScrollView
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
int firstVisible = manager.findFirstVisibleItemPosition();
int lastVisible = manager.findLastVisibleItemPosition();
Log.i("TAG", "onScrolled: " + firstVisible);
Log.i("TAG", "Last Index: " + lastVisible);
pageAdapter.changeItem(firstVisible, lastVisible);
}
});
createIndicator();
pageAdapter.notifyDataSetChanged();
}