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


Java RecyclerView.setPadding方法代碼示例

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


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

示例1: setRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void setRecyclerView(RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
    recyclerView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    ((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    int i = getResources().getDisplayMetrics().widthPixels;
    int y = DensityUtil.dp2px(getContext(), 90);
    int p = DensityUtil.dp2px(getContext(), 15);
    int padding = (3 * y + 2 * 3 * p + 2 * p - i) / (2 * 3);

    recyclerView.setPadding(
            padding,
            DensityUtil.dp2px(getContext(), 8),
            padding,
            DensityUtil.dp2px(getContext(), 8)
    );
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:18,代碼來源:BookcaseFragment.java

示例2: onCreateView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRecyclerView = new RecyclerView(getContext());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerView.setAdapter(new SimpleAdapter());
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setPadding(0, 0, 0,
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            // track for determining animation direction.
            mLastScrollOffsetY = dy;
        }
    });

    return mRecyclerView;
}
 
開發者ID:unixzii,項目名稱:android-SpringAnimator,代碼行數:19,代碼來源:RecyclerViewPreviewFragment.java

示例3: getRecyclerViewDialog

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public static AlertDialog.Builder getRecyclerViewDialog(Context context, BaseRecyclerAdapter.OnItemClickListener listener) {
    RecyclerView recyclerView = new RecyclerView(context);
    RecyclerView.LayoutParams params =
            new GridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    recyclerView.setPadding(Util.dipTopx(context, 16), Util.dipTopx(context, 16),
            Util.dipTopx(context, 16), Util.dipTopx(context, 16));
    recyclerView.setLayoutParams(params);
    recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
    CommentItemAdapter adapter = new CommentItemAdapter(context);
    adapter.setOnItemClickListener(listener);
    recyclerView.setAdapter(adapter);
    recyclerView.setOverScrollMode(OVER_SCROLL_NEVER);
    return getDialog(context)
            .setView(recyclerView)
            .setPositiveButton(null, null);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:17,代碼來源:DialogHelper.java

示例4: initPopupWindow

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 初始化顯示文件夾信息的popupWindow
 */
private void initPopupWindow() {
    popRecyclerview = new RecyclerView(this);
    popRecyclerview.setBackgroundColor(getResources().getColor(android.R.color.white));
    LinearLayoutManager layoutManager = new LinearLayoutManager
            (this, LinearLayoutManager.VERTICAL, false);
    popRecyclerview.setLayoutManager(layoutManager);
    popRecyclerview.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
    popRecyclerview.setPadding(0, Commonutil.dp2px(this, 5), 0, 0);

    int screenHeight = getResources().getDisplayMetrics().heightPixels;

    popupWindow = new PopupWindow(popRecyclerview, ViewGroup.LayoutParams.MATCH_PARENT,
            (int) (screenHeight * 0.6f));

    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(false);
    popupWindow.setAnimationStyle(R.style.popup_anim);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            fab.setVisibility(View.VISIBLE);
            WindowManager.LayoutParams attributes =
                    ScanImagesActivity.this.getWindow().getAttributes();
            attributes.alpha = 1;
            ScanImagesActivity.this.getWindow().setAttributes(attributes);
        }
    });

}
 
開發者ID:BittleDragon,項目名稱:MyRepository,代碼行數:35,代碼來源:ScanImagesActivity.java

示例5: initViews

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void initViews() {
    inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.ultimate_recycler_view_layout, this);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
    mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
    setScrollbars();
    mSwipeRefreshLayout.setEnabled(false);

    if (mRecyclerView != null) {
        mRecyclerView.setClipToPadding(mClipToPadding);
        if (mPadding != -1.1f) {
            mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
    }

    defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
    setDefaultScrollListener();

    /**
     * empty view setup
     */
    mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
    if (mEmptyId != 0) {
        mEmpty.setLayoutResource(mEmptyId);
        mEmptyView = mEmpty.inflate();
        mEmpty.setVisibility(View.GONE);
    }

    /**
     * floating button setup
     */
    mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
    mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:37,代碼來源:UltimateRecyclerView.java

示例6: initViews

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void initViews() {
    //super.initViews();
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.custom_recycler_view_layout, this);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
    mSwipeRefreshLayout = null;

    if (mRecyclerView != null) {

        mRecyclerView.setClipToPadding(mClipToPadding);
        if (mPadding != -1.1f) {
            mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
    }

    defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
    setDefaultScrollListener();

    mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
    mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);

    mEmpty.setLayoutResource(mEmptyId);

    mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);

    if (mEmptyId != 0)
        mEmptyView = mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

    if (mFloatingButtonId != 0) {
        mFloatingButtonView = mFloatingButtonViewStub.inflate();
        mFloatingButtonView.setVisibility(View.VISIBLE);
    }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:CustomUltimateRecyclerview.java

示例7: applyRecyclerViewPaddingForLayoutRes

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void applyRecyclerViewPaddingForLayoutRes(@NonNull RecyclerView recyclerView, @LayoutRes int res) {
    int padding;
    if (res == R.layout.item_grid) {
        padding = (int) (getResources().getDisplayMetrics().density * 2);
    } else {
        padding = 0;
    }
    recyclerView.setPadding(padding, padding, padding, padding);
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:10,代碼來源:AbsLibraryPagerRecyclerViewCustomGridSizeFragment.java

示例8: prepareListView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void prepareListView(Context context) {
	mListView = new RecyclerView(context);
	mAdapter = new ItemAdapter();

	mListView.setClipToPadding(false);
	mListView.setPadding(0, getResources().getDimensionPixelSize(R.dimen.stepper_margin_top), 0, 0);

	mListView.addItemDecoration(new VerticalSpaceItemDecoration(
			getResources().getDimensionPixelSize(R.dimen.vertical_stepper_item_space_height)));
	mListView.setLayoutManager(new LinearLayoutManager(context));
	mListView.setAdapter(mAdapter);

	addView(mListView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
 
開發者ID:fython,項目名稱:MaterialStepperView,代碼行數:15,代碼來源:VerticalStepperView.java

示例9: onCreateView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    RecyclerView recyclerView = (RecyclerView) inflater.inflate(
            R.layout.recycler_view, container, false);
    ContentAdapter adapter = new ContentAdapter(recyclerView.getContext());
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    // Set padding for Tiles
    int tilePadding = getResources().getDimensionPixelSize(R.dimen.tile_padding);
    recyclerView.setPadding(tilePadding, tilePadding, tilePadding, tilePadding);
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    return recyclerView;
}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:15,代碼來源:TileContentFragment.java

示例10: MenuBottomSheetDialog

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public MenuBottomSheetDialog(@NonNull Context context) {
    super(context);

    RecyclerView content = new RecyclerView(context);
    content.setLayoutManager(new LinearLayoutManager(context));
    content.setAdapter(new ItemAdapter());
    int verticalPadding = content.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_menu_vertical_margin);
    content.setPadding(0, verticalPadding, 0, verticalPadding);
    setContentView(content);

    content.setBackgroundColor(StyledAttributesHelper.getColor(context, R.attr.colorBackgroundFloating, 0));
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:13,代碼來源:MenuBottomSheetDialog.java

示例11: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * set the border around the View
 */
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (parent.getPaddingLeft() != _borderSpace) {
        parent.setPadding(_borderSpace, _borderSpace, _borderSpace, _borderSpace);
        parent.setClipToPadding(false);
    }

    outRect.top = _borderSpace;
    outRect.bottom = _borderSpace;
    outRect.left = _borderSpace;
    outRect.right = _borderSpace;
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:16,代碼來源:GridDecoration.java

示例12: initRecyclerView

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * Implement this method to customize the AbsListView
 */
protected void initRecyclerView(View view) {
    mRecycler = (RecyclerView) view.findViewById(android.R.id.list);
    tipView = (TextView) view.findViewById(R.id.tvTip);
    setItemAnimator(null);
    if (mRecycler != null) {
        mRecycler.setHasFixedSize(true);
        mRecycler.setClipToPadding(mClipToPadding);
        mInternalOnScrollListener = new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (mExternalOnScrollListener != null)
                    mExternalOnScrollListener.onScrolled(recyclerView, dx, dy);

            }

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (mExternalOnScrollListener != null)
                    mExternalOnScrollListener.onScrollStateChanged(recyclerView, newState);

            }
        };
        mRecycler.addOnScrollListener(mInternalOnScrollListener);

        if (mPadding != -1.0f) {
            mRecycler.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecycler.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
        if (mScrollbarStyle != -1) {
            mRecycler.setScrollBarStyle(mScrollbarStyle);
        }
        switch (mScrollbar) {
            case 0:
                setVerticalScrollBarEnabled(false);
                break;
            case 1:
                setHorizontalScrollBarEnabled(false);
                break;
            case 2:
                setVerticalScrollBarEnabled(false);
                setHorizontalScrollBarEnabled(false);
                break;
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:53,代碼來源:EasyRecyclerView.java


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