當前位置: 首頁>>代碼示例>>Java>>正文


Java StaggeredGridLayoutManager類代碼示例

本文整理匯總了Java中android.support.v7.widget.StaggeredGridLayoutManager的典型用法代碼示例。如果您正苦於以下問題:Java StaggeredGridLayoutManager類的具體用法?Java StaggeredGridLayoutManager怎麽用?Java StaggeredGridLayoutManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StaggeredGridLayoutManager類屬於android.support.v7.widget包,在下文中一共展示了StaggeredGridLayoutManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    ActivityCompat.setExitSharedElementCallback(this, exitTransitionCallback);
    super.onCreate(savedInstanceState);

    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);

    setContentView(R.layout.activity_gallery);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    ArrayList<String> imagesList = new ArrayList<>();
    for (int i = 1; i <= 23; i++)
        imagesList.add("http://ssninstincts.org.in/img/gallery/big/" + i + ".jpg");

    galleryAdapter = new GalleryAdapter(this, imagesList);
    StaggeredGridLayoutManager gridLayoutManager =
            new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
    galleryRecyclerView.setHasFixedSize(true);
    galleryRecyclerView.setLayoutManager(gridLayoutManager);
    galleryRecyclerView.setAdapter(galleryAdapter);
}
 
開發者ID:adithya321,項目名稱:Instincts-2k17,代碼行數:34,代碼來源:GalleryActivity.java

示例2: canChildScrollUp

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else if(view instanceof  RecyclerView){
            RecyclerView recyclerView = (RecyclerView)view;
            RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
            if(layoutManager instanceof LinearLayoutManager){
                int position = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
                return position != 0;
            }else{
                if(layoutManager instanceof StaggeredGridLayoutManager ){
                    StaggeredGridLayoutManager stagger = (StaggeredGridLayoutManager) layoutManager;
                    int[] positions = stagger.findFirstCompletelyVisibleItemPositions(null);
                    return positions[0] != 0;
                }else{
                    throw new RuntimeException("can not support this LayoutManager ");
                }
            }
        }else{
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:30,代碼來源:PtrDefaultHandler.java

示例3: initRecyclerView

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private void initRecyclerView() {
    mAdapter = new XRecyclerViewAdapter<>();
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setLoadingMore(this);
    recyclerView.setAdapter(
            mAdapter
                    .setLayoutId(R.layout.item_fiction_pt_list)
                    .setOnItemClickListener((view, position, info) -> {
                        String detailUrl = info.detailUrl;
                        if (TextUtils.isEmpty(detailUrl)) {
                            UIUtils.snackBar(mStatusView, R.string.pt_list_content_error);
                            return;
                        }
                        String bookinfo = detailUrl.replaceAll(".html", "/index.html").replaceAll("bookinfo", "html");
                        if (TextUtils.isEmpty(bookinfo)) {
                            UIUtils.snackBar(mStatusView, R.string.pt_list_content_error);
                            return;
                        }
                        FictionContentsActivity.getInstance(ApiConfig.Type.PIAO_TIAN, bookinfo, info.title);
                    })
                    .onXBind((holder, position, fictionModel) -> holder.setTextView(R.id.tv_title, fictionModel.title))
    );
}
 
開發者ID:7449,項目名稱:JsoupSample,代碼行數:25,代碼來源:PtFictionMoreActivity.java

示例4: ItemSenderUser

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
public ItemSenderUser(View itemView) {
    super(itemView);

    //Load fields
    this.tvClientName = (TextView) itemView.findViewById( R.id.tv_client_name );

    this.imageView = (ImageView) this.itemView.findViewById(R.id.iv_profile);
    //Set on click
    this.imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            click();
        }
    });
    StaggeredGridLayoutManager.LayoutParams st = (StaggeredGridLayoutManager.LayoutParams) this.itemView.getLayoutParams();
}
 
開發者ID:tec-ustp,項目名稱:SIIEScanner,代碼行數:17,代碼來源:ItemSenderUser.java

示例5: setRecyclerStlty

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private void setRecyclerStlty() {
    switch (mAdapter.getmStyle()) {
        case ListView:
        case HorizontalListView:
            setLView();
            break;
        case GridView:
        case HorizontalGridView:
            setGView();
            break;
        case WaterFall:
            StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(mNunColumns, StaggeredGridLayoutManager.VERTICAL);
            mRecyclerView.setLayoutManager(manager);
            break;
        case HorizontalWaterFall:
            StaggeredGridLayoutManager manager1 = new StaggeredGridLayoutManager(mNunColumns, StaggeredGridLayoutManager.HORIZONTAL);
            mRecyclerView.setLayoutManager(manager1);
            break;
        case MultiLayout:
            //多布局暫未實現
            break;

    }

}
 
開發者ID:liusmallpig,項目名稱:LowRecyclerView,代碼行數:26,代碼來源:RecyclerViewUtils.java

示例6: scrollToItem

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
/**
 * TODO 支持offset
 *
 * @param section
 * @param rowInSection
 * @param offset
 * @param animate
 * @return
 */
@Override
public UDBaseListOrRecyclerView scrollToItem(int section, int rowInSection, int offset, boolean animate) {
    final LVRecyclerView recyclerView = getLVRecyclerView();
    if (recyclerView != null) {
        if (animate) {
            recyclerView.smoothScrollToPosition(getPositionBySectionAndRow(section, rowInSection));
        } else {
            if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
                ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(getPositionBySectionAndRow(section, rowInSection), offset);
            } else if (recyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
                ((StaggeredGridLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(getPositionBySectionAndRow(section, rowInSection), offset);
            } else {
                recyclerView.scrollToPosition(getPositionBySectionAndRow(section, rowInSection));
            }
        }
    }
    return this;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:28,代碼來源:UDBaseRecyclerView.java

示例7: isLastRow

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private boolean isLastRow(RecyclerView parent, int pos, int rowCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        childCount = childCount - childCount % rowCount;
        if (pos >= childCount) { // 如果是最後一行,則不需要繪製底部分割線
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            childCount = childCount - childCount % rowCount;
            if (pos >= childCount) { // 如果是最後一行,則不需要繪製底部分割線
                return true;
            }
        } else {
            if ((pos + 1) % rowCount == 0) { // 如果是最後一行,則不需要繪製底部分割線
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:23,代碼來源:DividerGridItemDecoration.java

示例8: isLastColumn

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private boolean isLastColumn(RecyclerView parent, int pos, int rowCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % rowCount == 0) { // 如果是最後一列,則不需要繪製右側分割線
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % rowCount == 0) { // 如果是最後一列,則不需要繪製右側分割線
                return true;
            }
        } else {
            childCount = childCount - childCount % rowCount;
            if (pos >= childCount) { // 如果是最後一列,則不需要繪製右側分割線
                return true;
            }
        }
    }

    return false;
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:23,代碼來源:DividerGridItemDecoration.java

示例9: isLastRaw

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if (pos >= childCount - (childCount % spanCount)) {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        if (((StaggeredGridLayoutManager) layoutManager).getOrientation() == 1) {
            if (pos >= childCount - (childCount % spanCount)) {
                return true;
            }
        } else if ((pos + 1) % spanCount == 0) {
            return true;
        }
    }
    return false;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:DividerGridItemDecoration.java

示例10: initActivityCreated

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
@Override
protected void initActivityCreated() {
    if (!isPrepared || !isVisible || isLoad) {
        return;
    }
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.post(this::onRefresh);
    swipeRefreshLayout.setEnabled(false);
    mAdapter = new MultiAdapter<>(new ArrayList<>());
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(
            mAdapter.setXMultiAdapterListener(this)
    );

    setLoad();
}
 
開發者ID:7449,項目名稱:JsoupSample,代碼行數:18,代碼來源:PtFictionHomeFragment.java

示例11: isLastColum

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private boolean isLastColum(RecyclerView parent, int pos, int spanCount, int childCount) {
    RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % spanCount == 0)// 如果是最後一列,則不需要繪製右邊
        {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % spanCount == 0)// 如果是最後一列,則不需要繪製右邊
            {
                return true;
            }
        } else {
            childCount = childCount - childCount % spanCount;
            if (pos >= childCount)// 如果是最後一列,則不需要繪製右邊
                return true;
        }
    }
    return false;
}
 
開發者ID:OCNYang,項目名稱:RecyclerViewEvent,代碼行數:24,代碼來源:DividerGridItemDecoration.java

示例12: onCreateView

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
    listView = (RecyclerView) view.findViewById(R.id.list);
    listView.setHasFixedSize(true);
    listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
    List<ItemList> lists = new ArrayList<ItemList>();
    videoadapter = new VideoAdapter(lists);
    listView.setAdapter(videoadapter);

    mPresent = new VideoPresenter((VideoData.View) this);

    srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
    srfLayout.setOnRefreshListener(this);
    srfLayout.post(() -> onRefresh());
    return view;
}
 
開發者ID:popo1379,項目名稱:popomusic,代碼行數:19,代碼來源:KepuFragment.java

示例13: findFirstVisibleItemPosition

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
public int findFirstVisibleItemPosition() {
    switch (type) {
        case LinearLayout:
            return ((LinearLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case Grid:
            return ((GridLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case LinearLayoutWithHeaders:
            return ((LayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPosition();
        case StaggeredGridLayout:
            return ((StaggeredGridLayoutManager) recyclerView.getLayoutManager())
                    .findFirstVisibleItemPositions(null)[0];
        default:
            throw new IllegalStateException("Type of layoutManager unknown." +
                    "In this case this method needs to be overridden");
    }
}
 
開發者ID:jonashao,項目名稱:Samantha,代碼行數:20,代碼來源:RealmRecyclerView.java

示例14: setLayoutManger

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
public SmartRecycleView setLayoutManger(LayoutManagerType layoutManagerType, int orientation, int spanCout) {
    RecyclerView.LayoutManager layoutManager = null;
    if (layoutManagerType == LayoutManagerType.LINEAR_LAYOUT) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        linearLayoutManager.setOrientation(orientation);
        layoutManager = linearLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.GRID_LAYOUT) {
        GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, spanCout);
        gridLayoutManager.setOrientation(orientation);
        layoutManager = gridLayoutManager;
    } else if (layoutManagerType == LayoutManagerType.STAGGER_LAYOUT) {
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(spanCout, orientation);
        layoutManager = staggeredGridLayoutManager;
    }
    mRecyclerView.setLayoutManager(layoutManager);
    return this;
}
 
開發者ID:GaoGersy,項目名稱:MultiSelecter,代碼行數:18,代碼來源:SmartRecycleView.java

示例15: isLastColum

import android.support.v7.widget.StaggeredGridLayoutManager; //導入依賴的package包/類
private boolean isLastColum(RecyclerView parent, int pos, int spanCount,
                            int childCount) {
    LayoutManager layoutManager = parent.getLayoutManager();
    if (layoutManager instanceof GridLayoutManager) {
        if ((pos + 1) % spanCount == 0)// 如果是最後一列,則不需要繪製右邊
        {
            return true;
        }
    } else if (layoutManager instanceof StaggeredGridLayoutManager) {
        int orientation = ((StaggeredGridLayoutManager) layoutManager)
                .getOrientation();
        if (orientation == StaggeredGridLayoutManager.VERTICAL) {
            if ((pos + 1) % spanCount == 0)// 如果是最後一列,則不需要繪製右邊
            {
                return true;
            }
        } else {
            childCount = childCount - childCount % spanCount;
            if (pos >= childCount)// 如果是最後一列,則不需要繪製右邊
                return true;
        }
    }
    return false;
}
 
開發者ID:yiwent,項目名稱:Mobike,代碼行數:25,代碼來源:DividerGridItemDecoration.java


注:本文中的android.support.v7.widget.StaggeredGridLayoutManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。