本文整理匯總了Java中android.support.v7.widget.RecyclerView.HORIZONTAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.HORIZONTAL屬性的具體用法?Java RecyclerView.HORIZONTAL怎麽用?Java RecyclerView.HORIZONTAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.HORIZONTAL屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initViewContainer
public void initViewContainer(Activity activity, int localUid, HashMap<Integer, SurfaceView> uids, boolean isLandscape) {
boolean newCreated = initAdapter(activity, localUid, uids);
if (!newCreated) {
mGridVideoViewContainerAdapter.setLocalUid(localUid);
mGridVideoViewContainerAdapter.customizedInit(uids, true);
}
this.setAdapter(mGridVideoViewContainerAdapter);
int orientation = isLandscape ? RecyclerView.HORIZONTAL : RecyclerView.VERTICAL;
int count = uids.size();
if (count <= 2) { // only local full view or or with one peer
this.setLayoutManager(new LinearLayoutManager(activity.getApplicationContext(), orientation, false));
} else if (count > 2) {
int itemSpanCount = getNearestSqrt(count);
this.setLayoutManager(new GridLayoutManager(activity.getApplicationContext(), itemSpanCount, orientation, false));
}
mGridVideoViewContainerAdapter.notifyDataSetChanged();
}
示例2: onScrolled
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int firstVisibleItemPosition = 0;
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
// 判斷layout manager的類型
int type = judgeLayoutManager(layoutManager);
// 根據類型來計算出第一個可見的item的位置,由此判斷是否觸發到底部的監聽器
firstVisibleItemPosition = calculateFirstVisibleItemPos(type, layoutManager, firstVisibleItemPosition);
// 計算並判斷當前是向上滑動還是向下滑動
int orientation = getOrientation(type, layoutManager);
if (orientation == RecyclerView.VERTICAL) {
calculateScrollUpOrDown(firstVisibleItemPosition, dy);
} else if (orientation == RecyclerView.HORIZONTAL) {
calculateScrollUpOrDown(firstVisibleItemPosition, dx);
}
// 移動距離超過一定的範圍,我們監聽就沒有啥實際的意義了
mScrolledXDistance += dx;
mScrolledYDistance += dy;
mScrolledXDistance = (mScrolledXDistance < 0) ? 0 : mScrolledXDistance;
mScrolledYDistance = (mScrolledYDistance < 0) ? 0 : mScrolledYDistance;
onScrolled(mScrolledXDistance, mScrolledYDistance);
}
示例3: setTrailerList
private void setTrailerList() {
if (!trailers.isEmpty()){
tvTitleTrailers.setVisibility(View.VISIBLE);
vDividerTrailers.setVisibility(View.VISIBLE);
RvAdapterTrailers rvAdapterTrailers = new RvAdapterTrailers(trailers, this);
LinearLayoutManager llManagerTrailers = new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false);
rvTrailers.setLayoutManager(llManagerTrailers);
rvTrailers.setAdapter(rvAdapterTrailers);
}
if (!hasAskedForTrailers){
MoviesTask.getTrailers(movie.getId(), Constants.EN_LANGUAGE, this, this);
hasAskedForTrailers = true;
}
}
示例4: onDraw
/**
* 畫線
*/
@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);
}
}
示例5: getItemOffsets
/**
* 設置條目周邊的偏移量
*/
@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());
}
}