當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。