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


Java LinearLayoutManager.VERTICAL属性代码示例

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


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

示例1: initData

private void initData() {
    WriteLogUtil.init(this);

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration itemDecoration = new DividerItemDecoration(this, LinearLayoutManager.VERTICAL);
    mRecyclerView.addItemDecoration(itemDecoration);

    mDatas = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        String s = String.format("我是第%d个item", i);
        mDatas.add(s);
    }
    mAdapter = new ItemAdapter(this, mDatas);
    mRecyclerView.setAdapter(mAdapter);
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:16,代码来源:ToolBarSampleSnar.java

示例2: onDraw

@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {

    c.save();
    int left, right, top, bottom;
    int count = parent.getChildCount();
    if (!mBuilder.isShowLastDivider) {
        count -= 1;
    }

    Context context = parent.getContext();
    for (int i = 0; i < count; i++) {
        final View child = parent.getChildAt(i);
        int transitionX = (int) ViewCompat.getTranslationX(child);
        int transitionY = (int) ViewCompat.getTranslationY(child);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

        if (mBuilder.orientation == LinearLayoutManager.VERTICAL) {
            left = child.getLeft() - params.leftMargin + transitionX + ViewUtil.dp2px(context, mBuilder.leftMargin);
            top = child.getBottom() + params.bottomMargin;
            right = child.getRight() + params.rightMargin - ViewUtil.dp2px(context, mBuilder.rightMargin);
            bottom = top + mBuilder.dividerHeight + transitionY;
        } else {
            top = child.getTop() - params.topMargin + ViewUtil.dp2px(context, mBuilder.topMargin);
            bottom = child.getBottom() + params.bottomMargin + transitionY - ViewUtil.dp2px(context, mBuilder.bottomMargin);
            left = child.getRight() + params.rightMargin + transitionX;
            right = left + mBuilder.dividerHeight;
        }

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    c.restore();
}
 
开发者ID:crazysunj,项目名称:RecycylerViewItemDecoration,代码行数:34,代码来源:LinearLayoutDividerItemDecoration.java

示例3: initRecyclerView

private void initRecyclerView(){

        RecyclerView recyclerView = (RecyclerView) searchActivity.findViewById(R.id.recycler);
        recyclerView.setAdapter(classAdapter);

        userClasses = getFormatedClasses(userClasses);
        searchActivity.classAdapter = new ClassAdapter(userClasses, getApplicationContext(), recyclerView);
        classAdapter = searchActivity.classAdapter;
        classAdapter.setOnItemClickListener(callJoinClass());
        recyclerView.setAdapter(classAdapter);

        RecyclerView.LayoutManager layout = new LinearLayoutManager(application,
                LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layout);

        recyclerView.setOnScrollListener(new HidingScrollListener() {
            @Override
            public void onHide() {
                searchActivity.hideViews();
            }
            @Override
            public void onShow() {
                searchActivity.showViews();
            }
        });
    }
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:26,代码来源:ServerOperationSearchActivity.java

示例4: 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

示例5: ViewHelper

public ViewHelper(final ICheckInViewModel _viewModel, final ViewMainCheckInBinding binding, final Context _context) {
    viewModel = _viewModel;
    binding.setHelper(this);

    layoutManager = new LinearLayoutManager(_context, LinearLayoutManager.VERTICAL, false);
    adapter = new CheckInAdapter();
}
 
开发者ID:thinkmobiles,项目名称:Android-MVP-vs-MVVM-Samples,代码行数:7,代码来源:ViewHelper.java

示例6: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vertical);

    VerticalAdapter adapter = new VerticalAdapter(titles);
    MultiSnapRecyclerView recyclerView = (MultiSnapRecyclerView) findViewById(R.id.recycler_view);
    LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(manager);
    recyclerView.setAdapter(adapter);
}
 
开发者ID:TakuSemba,项目名称:MultiSnapRecyclerView,代码行数:11,代码来源:VerticalActivity.java

示例7: isSlideToBottom

/**
 * 判断是否到底部了
 * @param recyclerView
 * @return
 */
protected boolean isSlideToBottom(RecyclerView recyclerView) {
    if (recyclerView == null) return false;
    if(mOrientation == LinearLayoutManager.VERTICAL) {
        if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange())
            return true;
    }
    else
    {
        if (recyclerView.computeHorizontalScrollExtent() + recyclerView.computeHorizontalScrollOffset() >= recyclerView.computeHorizontalScrollRange())
            return true;
    }
    return false;
}
 
开发者ID:wanliyang1990,项目名称:RecyclerViewHeaderAndFooter,代码行数:18,代码来源:WapHeaderAndFooterAdapter.java

示例8: itemIsObscuredByHeader

/**
 * Determines if an item is obscured by a header
 *
 * @param parent      recycler view
 * @param item        to determine if obscured by header
 * @param header      that might be obscuring the item
 * @param orientation of the {@link RecyclerView}
 * @return true if the item view is obscured by the header view
 */
private boolean itemIsObscuredByHeader(RecyclerView parent, View item, View header, int orientation) {
    RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) item.getLayoutParams();
    mDimensionCalculator.initMargins(mTempRect1, header);

    int adapterPosition = parent.getChildAdapterPosition(item);
    if (adapterPosition == RecyclerView.NO_POSITION || mHeaderProvider.getHeader(parent, adapterPosition) != header) {
        // Resolves https://github.com/timehop/sticky-headers-recyclerview/issues/36
        // Handles an edge case where a trailing header is smaller than the current sticky header.
        return false;
    }

    if (orientation == LinearLayoutManager.VERTICAL) {
        int itemTop = item.getTop() - layoutParams.topMargin;
        int headerBottom = getListTop(parent) + header.getBottom() + mTempRect1.bottom + mTempRect1.top;
        if (itemTop >= headerBottom) {
            return false;
        }
    } else {
        int itemLeft = item.getLeft() - layoutParams.leftMargin;
        int headerRight = getListLeft(parent) + header.getRight() + mTempRect1.right + mTempRect1.left;
        if (itemLeft >= headerRight) {
            return false;
        }
    }

    return true;
}
 
开发者ID:sswukang,项目名称:RvAdapter,代码行数:36,代码来源:HeaderPositionCalculator.java

示例9: config

/**
 * @param layoutManager
 * @param adapter
 * @param shown         是否立刻显示内容
 */
public void config(LayoutManager layoutManager, Adapter adapter, boolean shown) {
    if (layoutManager == null) {
        mOrginalLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    } else {
        mOrginalLayoutManager = layoutManager;
    }
    mOrginalAdapter = adapter;
    if (shown) {
        mViewState = ViewState.LOADING;
        setViewState(ViewState.CONTENT);
    }
}
 
开发者ID:jiang111,项目名称:MultiRecyclerView,代码行数:17,代码来源:MultiRecyclerView.java

示例10: setUpRecyclerView

private void setUpRecyclerView() {
    recyclerViewLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(recyclerViewLayoutManager);

    // Adding items to RecyclerView.
    //addItemsToHorizontalRecyclerViewArrayList();

    verticalRecyclerViewAdapter = new VerticalRecyclerViewAdapter(getContext(), null);
    verticalLinearLayoutManager = new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(verticalLinearLayoutManager);
    recyclerView.setAdapter(verticalRecyclerViewAdapter);
}
 
开发者ID:akshaykale,项目名称:Android-Timeline-View,代码行数:12,代码来源:TimelineFragment.java

示例11: setItemOffsetsForHeader

/**
 * Sets the offsets for the first item in a section to make room for the header view
 *
 * @param itemOffsets rectangle to define offsets for the item
 * @param header      view used to calculate offset for the item
 * @param orientation used to calculate offset for the item
 */
private void setItemOffsetsForHeader(Rect itemOffsets, View header, int orientation) {
  mDimensionCalculator.initMargins(mTempRect, header);
  if (orientation == LinearLayoutManager.VERTICAL) {
    itemOffsets.top = header.getHeight() + mTempRect.top + mTempRect.bottom;
  } else {
    itemOffsets.left = header.getWidth() + mTempRect.left + mTempRect.right;
  }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:15,代码来源:StickyRecyclerHeadersDecoration.java

示例12: initUi

private void initUi() {
    RecyclerView v_profiles = (RecyclerView) findViewById(R.id.profiles);
    v_profiles.setHasFixedSize(true);

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    int prefIndex = pref.getInt(ConstantApp.PrefManager.PREF_PROPERTY_PROFILE_IDX, ConstantApp.DEFAULT_PROFILE_IDX);

    mVideoProfileAdapter = new VideoProfileAdapter(this, prefIndex);
    mVideoProfileAdapter.setHasStableIds(true);

    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    v_profiles.setLayoutManager(layoutManager);

    v_profiles.setAdapter(mVideoProfileAdapter);
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:15,代码来源:SettingsActivity.java

示例13: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report_detail);

    mActivityRecord = (ActivityRecord) getIntent().getSerializableExtra("activity_record");

    if (mActivityRecord == null) {
        finish();
        return;
    }

    ((TextView) findViewById(R.id.time)).setText(Utils.DATE_FORMAT.format(new Date(mActivityRecord.when)));
    String title = getString(R.string.record_cost, mActivityRecord.cost, mActivityRecord.activity_name);
    SpannableString ss = new SpannableString(title);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(mActivityRecord.cost >= StallBuster.getInstance().getThreshold() ? Constants.COLOR_WARNING : Constants.COLOR_NORMAL);
    ss.setSpan(colorSpan, 0, title.indexOf(" "), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
    ((TextView) findViewById(R.id.title)).setText(ss);
    mFilterCb = (CheckBox) findViewById(R.id.filter);
    mFilterCb.setText(getString(R.string.cb_hide_system_callbacks_executed_less_than_some_ms, StallBuster.getInstance().getCallbackThreshold()));
    mFilterCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mAdapter.setData(filteredRecords());
        }
    });

    mAdapter = new ReportDetailAdapter();
    RecyclerView container = (RecyclerView) findViewById(R.id.container);
    LinearLayoutManager lm = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    container.setLayoutManager(lm);
    container.addItemDecoration(new SimpleDecoration());
    mAdapter.setData(filteredRecords());
    container.setAdapter(mAdapter);
}
 
开发者ID:zhangjianli,项目名称:StallBuster,代码行数:35,代码来源:ReportDetailActivity.java

示例14: setTasks

@Override
public void setTasks(List<Task> tasks) {
    this.tasks = tasks;
    empty_state.setVisibility(View.GONE);
    recyclerView.setVisibility(View.VISIBLE);

    recyclerView.removeOnItemTouchListener(onItemTouchListener);
    recyclerView.addOnItemTouchListener(onItemTouchListener);

    linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    adapter = new TasksAdapter(TasksFragment.this.tasks);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);
}
 
开发者ID:The-LoneWolf,项目名称:Project-Assistant,代码行数:14,代码来源:TasksFragment.java

示例15: initDefaultHeaderOffset

private void initDefaultHeaderOffset(Rect headerMargins, RecyclerView recyclerView, View header, View firstView, int orientation) {
    int translationX, translationY;
    mDimensionCalculator.initMargins(mTempRect1, header);

    ViewGroup.LayoutParams layoutParams = firstView.getLayoutParams();
    int leftMargin = 0;
    int topMargin = 0;
    if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        leftMargin = marginLayoutParams.leftMargin;
        topMargin = marginLayoutParams.topMargin;
    }

    if (orientation == LinearLayoutManager.VERTICAL) {
        translationX = firstView.getLeft() - leftMargin + mTempRect1.left;
        translationY = Math.max(
                firstView.getTop() - topMargin - header.getHeight() - mTempRect1.bottom,
                getListTop(recyclerView) + mTempRect1.top);
    } else {
        translationY = firstView.getTop() - topMargin + mTempRect1.top;
        translationX = Math.max(
                firstView.getLeft() - leftMargin - header.getWidth() - mTempRect1.right,
                getListLeft(recyclerView) + mTempRect1.left);
    }

    headerMargins.set(translationX, translationY, translationX + header.getWidth(),
            translationY + header.getHeight());
}
 
开发者ID:sswukang,项目名称:RvAdapter,代码行数:28,代码来源:HeaderPositionCalculator.java


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