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