当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayoutManager.HORIZONTAL属性代码示例

本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.HORIZONTAL属性的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.HORIZONTAL属性的具体用法?Java LinearLayoutManager.HORIZONTAL怎么用?Java LinearLayoutManager.HORIZONTAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v7.widget.LinearLayoutManager的用法示例。


在下文中一共展示了LinearLayoutManager.HORIZONTAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChildDraw

@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    //判断当前是否是swipe方式:侧滑。
    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
        //1.ItemView--ViewHolder; 2.侧滑条目的透明度程度关联谁?dX(delta增量,范围:当前条目-width~width)。
        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        float alpha = 1;
        if (layoutManager instanceof LinearLayoutManager) {
            int orientation = ((LinearLayoutManager) layoutManager).getOrientation();
            if (orientation == LinearLayoutManager.HORIZONTAL) {
                alpha = 1 - Math.abs(dY) / viewHolder.itemView.getHeight();
            } else if (orientation == LinearLayoutManager.VERTICAL) {
                alpha = 1 - Math.abs(dX) / viewHolder.itemView.getWidth();
            }
        }
        viewHolder.itemView.setAlpha(alpha);//1~0
    }
    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:DefaultItemTouchHelperCallback.java

示例2: onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    this.mLayoutRes = R.layout.activity_main_with_profiles_selection;
    super.onCreate(savedInstanceState);
    super.mLastBackPressedTime = Long.MAX_VALUE - DOUBLE_BACK_PRESSED_TIMEOUT;

    this.mSelectableCriteria = getIntent().getParcelableExtra(Extra.CRITERIA);

    if (savedInstanceState != null) {
        mSelectedUsers = savedInstanceState.getParcelableArrayList(SAVE_SELECTED_USERS);
    }

    if (mSelectedUsers == null) {
        mSelectedUsers = new ArrayList<>();
    }

    RecyclerView.LayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    mProfilesAdapter = new SelectedProfilesAdapter(this, mSelectedUsers);
    mProfilesAdapter.setActionListener(this);

    mRecyclerView = findViewById(R.id.recycleView);
    if (mRecyclerView == null) {
        throw new IllegalStateException("Invalid view");
    }

    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.setAdapter(mProfilesAdapter);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:28,代码来源:SelectProfilesActivity.java

示例3: initSelectionRecycler

/**
     * 初始化选集recyclerView
     */
    public void initSelectionRecycler(List<String> urls) {
        this.urls = urls;
        mUpdateIndexText.setText("共"+urls.size()+"分P");

        mBangumiSelectionRecycler.setHasFixedSize(false);
        mBangumiSelectionRecycler.setNestedScrollingEnabled(false);
        LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
//        mLinearLayoutManager.setReverseLayout(true);
        mBangumiSelectionRecycler.setLayoutManager(mLinearLayoutManager);
        VideoDetaisSelectionAdapter mVideoDetaisSelectionAdapter = new VideoDetaisSelectionAdapter(mBangumiSelectionRecycler, urls, "");
        mBangumiSelectionRecycler.setAdapter(mVideoDetaisSelectionAdapter);
        mVideoDetaisSelectionAdapter.notifyItemForeground(0);
        mBangumiSelectionRecycler.scrollToPosition(0);
        mVideoDetaisSelectionAdapter.setOnItemClickListener((position, holder) -> {
            mVideoDetaisSelectionAdapter.notifyItemForeground(holder.getLayoutPosition());
            selectIndex = position;
            playVideo();
        });
    }
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:22,代码来源:VideoIntroductionFragment.java

示例4: onCreateViewHolder

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View layoutView = LayoutInflater.from(parent.getContext()).inflate(mLayoutId, parent, false);

    //create Recycler here
    MyRecyclerView recyclerView = (MyRecyclerView) layoutView.findViewById(R.id.horizontal_recycler_view);
    recyclerView.reboot(); //in case it's recycled

    // Create the right adapter for the recycler view
    HorizontalAdapter horizontalAdapter;
    horizontalAdapter = new HorizontalAdapter(recyclerView.getContext(), "", mTabNumber, mDarkTheme);

    // Set up the manager and adapter of the recycler view
    LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
    horizontalLayoutManager.scrollToPositionWithOffset(1, 0);
    recyclerView.setTag(0);
    recyclerView.setLayoutManager(horizontalLayoutManager);
    recyclerView.setAdapter(horizontalAdapter);
    recyclerView.setUp();

    return new ViewHolder(layoutView, recyclerView);
}
 
开发者ID:IdeaTrackerPlus,项目名称:IdeaTrackerPlus,代码行数:22,代码来源:ItemAdapter.java

示例5: getItemOffsets

@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (dividerDrawable == null) {
        return;
    }

    if (parent.getChildLayoutPosition(view) < 1) {
        return;
    }

    if (orientation == LinearLayoutManager.VERTICAL) {
        outRect.top = dividerDrawable.getIntrinsicHeight();
    } else if (orientation == LinearLayoutManager.HORIZONTAL) {
        outRect.left = dividerDrawable.getIntrinsicWidth();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:GridItemDecoration.java

示例6: getSpanCount

private int getSpanCount(RecyclerView parent)
{
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if(layoutManager instanceof GridLayoutManager)
    {
        return ((GridLayoutManager) layoutManager).getSpanCount();
    }
    else if(layoutManager instanceof StaggeredGridLayoutManager)
    {
        return ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
    }
    else if(layoutManager instanceof LinearLayoutManager)
    {
        int orientation = ((LinearLayoutManager) layoutManager).getOrientation();
        if(orientation == LinearLayoutManager.HORIZONTAL)
        {
            return parent.getChildCount();
        }
    }

    return 1;
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:22,代码来源:PrettyItemDecoration.java

示例7: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_grid_layout);
    Intent intent = getIntent();
    final int type = intent.getIntExtra(TYPE, 0);
    final int left = intent.getIntExtra(LEFT, 0);
    final int top = intent.getIntExtra(TOP, 0);
    final int right = intent.getIntExtra(RIGHT, 0);
    final int bottom = intent.getIntExtra(BOTTOM, 0);
    @Orientation final int orientation = intent.getIntExtra(ORIENTATION, LinearLayout.VERTICAL);
    recyclerview = (RecyclerView) findViewById(R.id.recyclerview);
    List<String> strings = Arrays.asList(MainActivity.getList());
    RecyclerViewAdapter adapter = new RecyclerViewAdapter(strings.subList(1, strings.size()), orientation == LinearLayoutManager.HORIZONTAL);
    RecyclerView.ItemDecoration itemDecoration;
    if (type == SPACE) {
        itemDecoration = new GridLayoutSpaceItemDecoration.Builder()
                .build();
    } else if (type == DIVIDER) {
        itemDecoration = new GridLayoutDividerItemDecoration.Builder()
                .setDividerColor(Color.RED)
                .setLeftMargin(left)
                .setTopMargin(top)
                .setRightMargin(right)
                .setBottomMargin(bottom)
                .build();
    } else {
        itemDecoration = new GridLayoutDividerItemDecoration.Builder()
                .setLeftMargin(left)
                .setDividerDrawable(getResources().getDrawable(R.drawable.red2blue))
                .setTopMargin(top)
                .setRightMargin(right)
                .setBottomMargin(bottom)
                .build();
    }
    recyclerview.setLayoutManager(new GridLayoutManager(this, 3, orientation, false));
    recyclerview.addItemDecoration(itemDecoration);
    recyclerview.setAdapter(adapter);
}
 
开发者ID:crazysunj,项目名称:RecycylerViewItemDecoration,代码行数:39,代码来源:GridLayoutActivity.java

示例8: getItemOffsets

/**
 * Determines the size and location of offsets between items in the parent
 * RecyclerView.
 *
 * @param outRect The {@link Rect} of offsets to be added around the child
 *                view
 * @param view    The child view to be decorated with an offset
 * @param parent  The RecyclerView onto which dividers are being added
 * @param state   The current RecyclerView.State of the RecyclerView
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    super.getItemOffsets(outRect, view, parent, state);

    if (parent.getChildAdapterPosition(view) <= mWrapAdapter.getHeadersCount() + 1) {
        return;
    }
    mOrientation = ((LinearLayoutManager) parent.getLayoutManager()).getOrientation();
    if (mOrientation == LinearLayoutManager.HORIZONTAL) {
        outRect.left = mDivider.getIntrinsicWidth();
    } else if (mOrientation == LinearLayoutManager.VERTICAL) {
        outRect.top = mDivider.getIntrinsicHeight();
    }
}
 
开发者ID:leobert-lan,项目名称:UiLib,代码行数:24,代码来源:LRecyclerView.java

示例9: setCategoryData

@BindingAdapter("categoryData")
public static void setCategoryData(RecyclerView view, List<ItemList> list) {

    CategoryPopAdapter categoryPopAdapter = new CategoryPopAdapter(view.getContext());
    categoryPopAdapter.addAll(list);
    LinearLayoutManager manager = new LinearLayoutManager(view.getContext()
            , LinearLayoutManager.HORIZONTAL, false);
    view.setLayoutManager(manager);
    view.setAdapter(categoryPopAdapter);
}
 
开发者ID:monkeywiiu,项目名称:Discover,代码行数:10,代码来源:DatabindingUtil.java

示例10: initTrailersView

private void initTrailersView() {
    movieTrailersAdapter.setOnItemClickListener((itemView, position) -> onMovieVideoClicked(position));
    trailersRecyclerView.setAdapter(movieTrailersAdapter);
    trailersRecyclerView.setItemAnimator(new DefaultItemAnimator());
    LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    trailersRecyclerView.setLayoutManager(layoutManager);
}
 
开发者ID:oantajames,项目名称:mdb-android-application,代码行数:7,代码来源:MovieDetailsActivity.java

示例11: onCreate

private void onCreate() {
    adapter = new RibbonTagAdapter();
    setAdapter(adapter);

    LayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    setLayoutManager(layoutManager);

    RibbonTagItemDecoration decoration = new RibbonTagItemDecoration(space);
    addItemDecoration(decoration);
}
 
开发者ID:battleent,项目名称:android-RibbonViews,代码行数:10,代码来源:RibbonTagListView.java

示例12: DividerListItemDecoration

public DividerListItemDecoration(Context context, int orientation, int drawableId) {
    if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) {
        throw new IllegalArgumentException("Orientation Only Support LinearLayoutManager.VERTICAL " +
                "or LinearLayoutManager.HORIZONTAL");
    }
    mOrientation = orientation;

    if (drawableId == -1) {
        final TypedArray a = context.obtainStyledAttributes(ATTRS);
        mDivider = a.getDrawable(0);
        a.recycle();
    } else {
        mDivider = ContextCompat.getDrawable(context, drawableId);
    }
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:15,代码来源:DividerListItemDecoration.java

示例13: setCurrentPager

/**
 * 滚动到指定页
 */
public void setCurrentPager(int pager) {
    if (mCurrentPager != pager) {
        final LayoutManager layoutManager = getLayoutManager();
        if (layoutManager instanceof LinearLayoutManager) {
            final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
            final int orientation = linearLayoutManager.getOrientation();
            if (orientation == LinearLayoutManager.HORIZONTAL) {
                to(pager * getRawWidth() - mCurrentPager * getRawWidth(), 0);
            } else {
                to(0, pager * getRawWidth() - mCurrentPager * getRawWidth());
            }
        }
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:17,代码来源:RecyclerViewPager.java

示例14: getView

@Override
public View getView(int position, View view, ViewGroup parent) {

    //Recycle made complicated with big text option
    if (view == null) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        view = inflater.inflate(R.layout.recycler_view_item, parent, false);
    }

    MyRecyclerView horizontal_recycler_view = (MyRecyclerView) view.findViewById(R.id.horizontal_recycler_view);
    horizontal_recycler_view.reboot(); //in case it's recycled

    // Get the text and id of the idea
    ArrayList<Pair<Integer, String>> ideas = mDbHelper.searchIdeas(subString);
    Pair<Integer, String> pair = ideas.get(position);

    // Create the right adapter for the recycler view
    HorizontalAdapter horizontalAdapter;
    horizontalAdapter = new HorizontalAdapter(horizontal_recycler_view.getContext(), pair.second, 4, mDarkTheme);

    // Set up the manager and adapter of the recycler view
    LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(horizontal_recycler_view.getContext(), LinearLayoutManager.HORIZONTAL, false);
    horizontalLayoutManager.scrollToPositionWithOffset(1, 0);
    horizontal_recycler_view.setTag(pair.first);
    horizontal_recycler_view.setLayoutManager(horizontalLayoutManager);
    horizontal_recycler_view.setAdapter(horizontalAdapter);
    horizontal_recycler_view.setUp();

    //return the entire view
    return view;
}
 
开发者ID:IdeaTrackerPlus,项目名称:IdeaTrackerPlus,代码行数:31,代码来源:SearchListAdapter.java

示例15: calculateDistanceToFinalSnap

@Nullable
@Override
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager, @NonNull View targetView) {
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) targetView.getLayoutParams();
    int position = params.getViewAdapterPosition();
    int left = targetView.getLeft();
    int right = targetView.getRight();
    int top = targetView.getTop();
    int bottom = targetView.getBottom();
    ViewGroup viewGroup = (ViewGroup) targetView.getParent();

    int[] out = new int[]{0, 0};
    boolean isLastItem;
    if (mOrientation == LinearLayoutManager.HORIZONTAL) {
        isLastItem = position == layoutManager.getItemCount() - 1/*最后一个*/ && right == viewGroup.getMeasuredWidth();
        out[0] = left;
        out[1] = 0;
    } else {
        isLastItem = position == layoutManager.getItemCount() - 1/*最后一个*/ && bottom == viewGroup.getMeasuredHeight();
        out[0] = 0;
        out[1] = top;
    }

    if (mOnPageListener != null && mCurrentPosition != position) {
        int currentPosition = mCurrentPosition;
        boolean listener = false;
        if (mOrientation == LinearLayoutManager.HORIZONTAL && (out[0] == 0 || isLastItem)) {
            listener = true;
        } else if (mOrientation == LinearLayoutManager.VERTICAL && (out[1] == 0 || isLastItem)) {
            listener = true;
        }

        if (listener) {
            mCurrentPosition = position;
            mOnPageListener.onPageSelector(mCurrentPosition);
            mOnPageListener.onPageSelector(currentPosition, mCurrentPosition);
        }
    }
    return out;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:40,代码来源:RPagerSnapHelper.java


注:本文中的android.support.v7.widget.LinearLayoutManager.HORIZONTAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。