I have a recyclerview displaying list of items in horizontal. I am displaying a list of articles with title and description:
mRecyclerView = findViewById(R.id.rvmain);
mRecyclerView.setOnFlingListener(null);
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(mRecyclerView);
mLayoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new MainActivityRVAdapter(postsModels,MainActivity.this);
mRecyclerView.setAdapter(mAdapter);
In my menu I have two items onclicking clicking which i want to change the font size of that particular recyclerview which is shown
<item
android:id="@+id/fontincrease"
android:title="@string/fontincrease"
app:showAsAction="always"
/>
<item
android:id="@+id/fontdecrease"
android:title="@string/fontdecrease"
app:showAsAction="always"
/>
Now how to process from here i am not able to understand
I know the code to increase font size:
float size = mViewShabad.getTextSize()*1.1f;
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
I have to get the viewholder and increase the font of the description.
I googled and got the below line to be used to access the elements in the viewholder.
int position = ((LinearLayoutManager)mRecyclerView.getLayoutManager()).findFirstVisibleItemPosition();
(TextView) mRecyclerView.findViewHolderForAdapterPosition(position).itemView.findViewById(R.id.title)
I am able to change the font size, but i want to reset it when i scroll
I am trying:
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
{
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
// what to do here so that everything is shown the default way
}
});