Java Code Examples for android.support.v7.widget.RecyclerView#setBackgroundColor()

The following examples show how to use android.support.v7.widget.RecyclerView#setBackgroundColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewHelper.java    From FABRevealMenu-master with Apache License 2.0 7 votes vote down vote up
public RecyclerView generateMenuView(boolean enableNestedScrolling) {
    //Create menu view
    RecyclerView mMenuView = new RecyclerView(mContext);
    mMenuView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
    mMenuView.setBackgroundColor(Color.TRANSPARENT);
    mMenuView.setLayoutParams(matchParams);
    final int padding = dpToPx(mContext, 10);
    mMenuView.setPadding(padding, padding, padding, padding);
    mMenuView.setNestedScrollingEnabled(enableNestedScrolling);
    return mMenuView;
}
 
Example 2
Source File: QuickReplyListView.java    From imsdk-android with MIT License 6 votes vote down vote up
private RecyclerView getListView(final List<String> quickReplies, final OnQuickRepliesClickListener listener) {
    RecyclerView recyclerView = new RecyclerView(context);
    recyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setVerticalScrollBarEnabled(false);
    recyclerView.setHorizontalScrollBarEnabled(false);
    recyclerView.setBackgroundColor(Color.TRANSPARENT);

    QuickReplyAdapter quickReplyAdapter = new QuickReplyAdapter(R.layout.atom_ui_quickreply_item, quickReplies);
    quickReplyAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            listener.onQuickReplyClick(quickReplies.get(position));
        }

    });
    recyclerView.setAdapter(quickReplyAdapter);
    return recyclerView;
}
 
Example 3
Source File: LiteIconActivityV2.java    From NanoIconPackLite with Apache License 2.0 5 votes vote down vote up
private void init() {
    setTheme(android.R.style.Theme_DeviceDefault_Wallpaper);

    displayMetrics = getResources().getDisplayMetrics();

    adapter = new IconAdapter();

    layoutManager = new GridLayoutManager(this, calculateGridNum());
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.isCate(position) ? layoutManager.getSpanCount() : 1;
        }
    });

    RecyclerView recyclerView = new RecyclerView(this);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);

    ViewGroup.LayoutParams lpRv = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    recyclerView.setLayoutParams(lpRv);
    recyclerView.setBackgroundColor(0x80808080); // 保证图标视觉

    setContentView(recyclerView);
}
 
Example 4
Source File: LiteIconActivity.java    From NanoIconPackLite with Apache License 2.0 5 votes vote down vote up
private void init() {
    setTheme(android.R.style.Theme_DeviceDefault_Wallpaper);

    displayMetrics = getResources().getDisplayMetrics();

    adapter = new IconAdapter();

    layoutManager = new GridLayoutManager(this, calculateGridNum());
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.isCate(position) ? layoutManager.getSpanCount() : 1;
        }
    });

    RecyclerView recyclerView = new RecyclerView(this);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);

    ViewGroup.LayoutParams lpRv = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    recyclerView.setLayoutParams(lpRv);
    recyclerView.setBackgroundColor(0x80808080); // 保证图标视觉

    setContentView(recyclerView);
}
 
Example 5
Source File: BaseFragment.java    From Bookster with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View mNoSearchView = inflater.inflate(R.layout.view_no_search, null, false);
    mNoFoundView = inflater.inflate(R.layout.view_no_found, null, false);
    mSearchingView = inflater.inflate(R.layout.view_searching, null, false);
    View view = LayoutInflater.from(getContext()).inflate(R.layout.recycler_view, container, false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    if (PreferenceManager.getDefaultSharedPreferences(getContext())
            .getBoolean("dark_theme",false))
    {
        mRecyclerView.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.DarkRecyclerViewBackground));
        mAdapter = new MyItemAdapter(ContextCompat.getColor(getContext(),R.color.DarkMainColor));
    }else
    mAdapter = new MyItemAdapter(ContextCompat.getColor(getContext(),R.color.DayColor));
    mAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
    mAdapter.setEmptyView(mNoSearchView);
    mRecyclerView.setAdapter(mAdapter);


    initLoadMore();
    setOnClickEvent();
    initReLoad();
    return view;
}
 
Example 6
Source File: PopMenuLayout.java    From PopMenuLayout with MIT License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr){
    initAttrs(context, attrs, defStyleAttr);
    mMenuShow = new boolean[SUPPORT_MENU_LEVEL];
    for (int i = 0; i < SUPPORT_MENU_LEVEL; i++) {
        mMenuShow[i] = i == 0;
    }
    mContext = context;
    mMenus = new ArrayList<MenuBean>();
    m1LevelMenuAdapter = new MenuAdapter(mContext, mMenus, mLayoutManagerOrientation);
    m1LevelMenuAdapter.setMenuHeight((int) mLevel1MenuItemHeight);
    m1LevelMenuAdapter.setOnMenuClickListener(new OnMenuClickListener() {
        @Override
        public void onMenuClick(int level1Index, int level2Index, int level3Index) {
            dealMenuClickEvent(level1Index, level2Index, level3Index);
        }
    });
    invalidateViewsAttr();

    recyclerView = new RecyclerView(mContext, attrs, defStyleAttr);
    recyclerView.setId(R.id.recyclerView);
    mLayoutManager = new LinearLayoutManager(mContext);
    mLayoutManager.setOrientation(mLayoutManagerOrientation);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setBackgroundColor(mLevel1MenuLayoutBgColor);

    LayoutParams params = new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    recyclerView.setLayoutParams(params);

    addView(recyclerView);
}
 
Example 7
Source File: ImageScannerDialogLayout.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
private void initListView() {


        mListView = new RecyclerView(mContext);
        LinearLayoutManager layoutmanager = new LinearLayoutManager(mContext);
        layoutmanager.setOrientation(LinearLayoutManager.VERTICAL);
        mListView.setLayoutManager(layoutmanager);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.topMargin = mTopLayoutHeight;
        mListView.setLayoutParams(params);
        mListView.setBackgroundColor(Color.WHITE);

        imageFloderAdapter = new ImageFloderAdapter(mContext);
        imageFloderAdapter.mOnItemClickListener = new IWidgetClickListener<ImageFolderBean>() {
            @Override
            public void onClick(ImageFolderBean imageFolderBean) {
                initGridView();

                imageModel = new ImageModel();
                imageModel.onCreate(mContext, ImageScannerDialogLayout.this);
                imageModel.load(imageFolderBean);

                mListView.setVisibility(GONE);
                mTitleView.setText("选择图片");
                mCancelView.setVisibility(VISIBLE);
            }
        };
        mListView.setAdapter(imageFloderAdapter);

        imageFolderModel = new ImageFolderModel();
        imageFolderModel.onCreate(mContext, new IImageMediaCallback() {
            @Override
            public void onImageLoad(Cursor cursor) {
                imageFloderAdapter.swapCursor(cursor);
            }

            @Override
            public void onImageReset() {
                imageFloderAdapter.swapCursor(null);
            }
        });
        imageFolderModel.loadImageFolders();

        addView(mListView);
    }