Java Code Examples for android.support.v7.widget.RecyclerView#HORIZONTAL

The following examples show how to use android.support.v7.widget.RecyclerView#HORIZONTAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathLayoutManager.java    From PathLayoutManager with Apache License 2.0 5 votes vote down vote up
/**
 * 设置滑动方向
 *
 * @param orientation {@see RecyclerView.HORIZONTAL}
 *                    {@see RecyclerView.VERTICAL}
 */
@SuppressWarnings("SuspiciousNameCombination")
public void setOrientation(@RecyclerView.Orientation int orientation) {
    if (mOrientation != orientation) {
        mOrientation = orientation;
        if (orientation == RecyclerView.HORIZONTAL) {
            mOffsetX = mOffsetY;
            mOffsetY = 0;
        } else {
            mOffsetY = mOffsetX;
            mOffsetX = 0;
        }
    }
}
 
Example 2
Source File: MyDecorationOne.java    From MaterialDesignDemo with MIT License 5 votes vote down vote up
/**
 * 画线
 */
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(c, parent, state);
    if (orientation == RecyclerView.HORIZONTAL) {
        drawVertical(c, parent, state);
    } else if (orientation == RecyclerView.VERTICAL) {
        drawHorizontal(c, parent, state);
    }
}
 
Example 3
Source File: MyDecorationOne.java    From MaterialDesignDemo with MIT License 5 votes vote down vote up
/**
 * 设置条目周边的偏移量
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);
    if (orientation == RecyclerView.HORIZONTAL) {
        //画垂直线
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    } else if (orientation == RecyclerView.VERTICAL) {
        //画水平线
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    }
}
 
Example 4
Source File: PathLayoutManager.java    From PathLayoutManager with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canScrollHorizontally() {
    return mOrientation == RecyclerView.HORIZONTAL;
}
 
Example 5
Source File: BindingUtils.java    From android-mvvm with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("layout_vertical")
public static void bindLayoutManager(@NonNull RecyclerView recyclerView, boolean vertical) {
    int orientation = vertical ? RecyclerView.VERTICAL : RecyclerView.HORIZONTAL;
    recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext(), orientation, false));
}