HorizontalPicker
HorizontalPicker copied to clipboard
How can I use it on landscape
I can't use it on landscape,can you help me to finish it?
what is the issue?
It can not be scrolled to first and last item in wide screen. when I'm trying to scroll the items in some wide screen like tablets it stucks on second or one before the last item. EDIT: Sorry I thought it would be better to mention that I completely followed the document. this is my recyclerview code:
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_registerNewCar_model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/view1"
android:layout_centerInParent="true"
android:clipToPadding="false"
android:paddingLeft="@dimen/dimen_185"
android:paddingRight="@dimen/dimen_185"
/>
What about this:
recyclerView.setPadding(screenwidth / 2, 0, screenwidth / 2, 0)
It solved my issue. Thank you.
If someone is forking the code, onAttachedToWindow
function can overridden in PickerLayoutManager
class to automatically solve the issue:
@Override
public void onAttachedToWindow(final RecyclerView view) {
super.onAttachedToWindow(view);
final DisplayMetrics displayMetrics = view.getContext().getResources().getDisplayMetrics();
final int screenWidth = displayMetrics.widthPixels;
view.setPadding(screenWidth / 2, 0, screenWidth / 2, 0);
}