Java Code Examples for androidx.recyclerview.widget.RecyclerView#setBackgroundColor()

The following examples show how to use androidx.recyclerview.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: NestedPageFragment.java    From SmoothRefreshLayout with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(
        @NonNull LayoutInflater inflater,
        @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_nested_page, container, false);
    RecyclerView recyclerView = view.findViewById(R.id.recyclerView_nested_page);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setHasFixedSize(true);
    recyclerView.setBackgroundColor(mColor);
    recyclerView.setTranslationX(-getResources().getDisplayMetrics().widthPixels / 2f);
    mAdapter = new RecyclerViewAdapter(getActivity(), inflater);
    recyclerView.setAdapter(mAdapter);
    mAdapter.updateData(mList);
    return view;
}
 
Example 2
Source File: BrickFragment.java    From brickkit-android with Apache License 2.0 6 votes vote down vote up
@Override
@CallSuper
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view;
    if (orientation() == OrientationHelper.VERTICAL) {
        view = inflater.inflate(R.layout.vertical_fragment_brick, container, false);
    } else {
        view = inflater.inflate(R.layout.horizontal_fragment_brick, container, false);
    }

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setBackgroundColor(recyclerViewBackground);
    ((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    dataManager.setRecyclerView(getContext(), recyclerView, orientation(), reverse(), view);
    return view;
}
 
Example 3
Source File: AdvancedListFragment.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView = (RecyclerView) view;
    mRecyclerView.setBackgroundColor(0xFF323232);
    mAdapter = new AdvancedListAdapter();
    mRecyclerView.setAdapter(mAdapter);
    int divider = getResources().getDimensionPixelSize(R.dimen.divider);
    mRecyclerView.setPadding(divider/2,divider/2,divider/2,divider/2);
    RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(),2);

    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.addItemDecoration(new SpaceItemDecoration(divider));
    initCells();
}
 
Example 4
Source File: PictureMultiCuttingActivity.java    From Matisse-Kotlin with Apache License 2.0 5 votes vote down vote up
/**
 * 动态添加多图裁剪底部预览图片列表
 */
private void addPhotoRecyclerView() {
    mRecyclerView = new RecyclerView(this);
    mRecyclerView.setId(R.id.id_recycler);
    mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
    RelativeLayout.LayoutParams lp =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, dip2px(80));
    mRecyclerView.setLayoutParams(lp);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    resetCutDataStatus();
    list.get(cutIndex).setCut(true);
    adapter = new PicturePhotoGalleryAdapter(this, list);
    mRecyclerView.setAdapter(adapter);
    adapter.setOnItemClickListener((position, view) -> {
        if (cutIndex == position) {
            return;
        }
        cutIndex = position;
        resetCutData();
    });

    uCropMultiplePhotoBox.addView(mRecyclerView);
    changeLayoutParams();
    FrameLayout uCropFrame = findViewById(R.id.ucrop_frame);
    ((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.id_recycler);
}
 
Example 5
Source File: MongolMenu.java    From mongol-library with MIT License 5 votes vote down vote up
private void createContentViewIfNeeded() {
    if (mContentView != null) return;
    RecyclerView recyclerView = new RecyclerView(mContext);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext,
            LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(layoutManager);
    MenuItemAdapter adapter = new MenuItemAdapter(mContext);
    recyclerView.setAdapter(adapter);
    recyclerView.setBackgroundColor(Color.WHITE);
    mContentView = recyclerView;
}
 
Example 6
Source File: MenuBottomSheetDialog.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
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));
}
 
Example 7
Source File: BrickDialogFragment.java    From brickkit-android with Apache License 2.0 5 votes vote down vote up
@Override
@CallSuper
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view;
    if (orientation() == OrientationHelper.VERTICAL) {
        view = inflater.inflate(R.layout.vertical_fragment_brick, container, false);
    } else {
        view = inflater.inflate(R.layout.horizontal_fragment_brick, container, false);
    }

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setBackgroundColor(recyclerViewBackground);
    dataManager.setRecyclerView(getContext(), recyclerView, orientation(), reverse(), view);
    return view;
}
 
Example 8
Source File: PreferenceFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Override
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
                                         Bundle savedInstanceState) {
    RecyclerView view = super.onCreateRecyclerView(inflater, parent, savedInstanceState);
    view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.background));

    int padding = (int) getResources().getDimension(R.dimen.global_padding);
    view.setPadding(padding, 0, padding, 0);

    view.addItemDecoration(new BackgroundDecoration(android.R.id.title));
    view.addItemDecoration(new DividerDecoration(getContext(), android.R.id.title));

    return view;
}
 
Example 9
Source File: EditFragment.java    From pandora with Apache License 2.0 4 votes vote down vote up
@Override
protected View getLayoutView() {
    View wrapper;
    editText = new EditText(getContext());
    int padding = ViewKnife.dip2px(16);
    editText.setPadding(padding, padding, padding, padding);
    editText.setBackgroundColor(Color.WHITE);
    editText.setGravity(Gravity.START | Gravity.TOP);
    editText.setTextColor(ViewKnife.getColor(R.color.pd_label_dark));
    editText.setLineSpacing(0, 1.2f);

    String[] options = getArguments().getStringArray(PARAM3);
    if (options != null && options.length > 0) {
        LinearLayout layout = new LinearLayout(getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        wrapper = layout;
        RecyclerView recyclerView = new RecyclerView(getContext());
        recyclerView.setBackgroundColor(Color.WHITE);
        LinearLayoutManager manager = new LinearLayoutManager(getContext());
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
        UniversalAdapter adapter = new UniversalAdapter();
        recyclerView.setAdapter(adapter);
        adapter.setListener(new UniversalAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, BaseItem item) {
                notifyResult(((OptionItem)item).data);
            }
        });
        List<BaseItem> items = new ArrayList<>(options.length);
        for (String option : options) {
            items.add(new OptionItem(option));
        }
        adapter.setItems(items);

        LinearLayout.LayoutParams recyclerParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewKnife.dip2px(50)
        );
        layout.addView(recyclerView, recyclerParam);
        LinearLayout.LayoutParams editParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
        );
        layout.addView(editText, editParam);
    } else {
        wrapper = editText;
    }
    return wrapper;
}
 
Example 10
Source File: PictureMultiCuttingActivity.java    From PictureSelector with Apache License 2.0 4 votes vote down vote up
/**
 * 动态添加多图裁剪底部预览图片列表
 */
private void addPhotoRecyclerView() {
    boolean isMultipleSkipCrop = getIntent().getBooleanExtra(UCrop.Options.EXTRA_SKIP_MULTIPLE_CROP, true);
    mRecyclerView = new RecyclerView(this);
    mRecyclerView.setId(R.id.id_recycler);
    mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
    RelativeLayout.LayoutParams lp =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                    ScreenUtils.dip2px(this, 80));
    mRecyclerView.setLayoutParams(lp);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    if (isAnimation) {
        LayoutAnimationController animation = AnimationUtils
                .loadLayoutAnimation(getApplicationContext(), R.anim.ucrop_layout_animation_fall_down);
        mRecyclerView.setLayoutAnimation(animation);
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    // 解决调用 notifyItemChanged 闪烁问题,取消默认动画
    ((SimpleItemAnimator) mRecyclerView.getItemAnimator())
            .setSupportsChangeAnimations(false);
    resetCutDataStatus();
    list.get(cutIndex).setCut(true);
    mAdapter = new PicturePhotoGalleryAdapter(this, list);
    mRecyclerView.setAdapter(mAdapter);
    if (isMultipleSkipCrop) {
        mAdapter.setOnItemClickListener(new PicturePhotoGalleryAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, View view) {
                CutInfo cutInfo = list.get(position);
                if (MimeType.isHasVideo(cutInfo.getMimeType())) {
                    return;
                }
                if (cutIndex == position) {
                    return;
                }
                resetLastCropStatus();
                cutIndex = position;
                oldCutIndex = cutIndex;
                resetCutData();
            }
        });
    }
    uCropPhotoBox.addView(mRecyclerView);
    changeLayoutParams(mShowBottomControls);

    // 裁剪框居于RecyclerView之上
    FrameLayout uCropFrame = findViewById(R.id.ucrop_frame);
    ((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.id_recycler);

    // RecyclerView居于BottomControls之上
    ((RelativeLayout.LayoutParams) mRecyclerView.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.controls_wrapper);
}
 
Example 11
Source File: MobiComQuickConversationFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View list = inflater.inflate(R.layout.mobicom_message_list, container, false);

    recyclerView = (RecyclerView) list.findViewById(R.id.messageList);
    recyclerView.setBackgroundColor(getResources().getColor(R.color.conversation_list_all_background));

    if (messageList != null && !messageList.contains(null)) {
        messageList.add(null);
    }
    recyclerAdapter = new QuickConversationAdapter(getContext(), messageList, null);
    recyclerAdapter.setAlCustomizationSettings(alCustomizationSettings);

    linearLayoutManager = new AlLinearLayoutManager(getContext());
    linearLayoutManager.setOrientation(AlLinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);

    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext());
    recyclerView.addItemDecoration(dividerItemDecoration);
    recyclerView.setAdapter(recyclerAdapter);
    toolbar = (Toolbar) getActivity().findViewById(R.id.my_toolbar);
    toolbar.setClickable(false);
    fabButton = (ImageButton) list.findViewById(R.id.fab_start_new);
    loading = true;
    LinearLayout individualMessageSendLayout = (LinearLayout) list.findViewById(R.id.individual_message_send_layout);
    LinearLayout extendedSendingOptionLayout = (LinearLayout) list.findViewById(R.id.extended_sending_option_layout);

    individualMessageSendLayout.setVisibility(View.GONE);
    extendedSendingOptionLayout.setVisibility(View.GONE);

    emptyTextView = (TextView) list.findViewById(R.id.noConversations);
    emptyTextView.setTextColor(Color.parseColor(alCustomizationSettings.getNoConversationLabelTextColor().trim()));

    fabButton.setVisibility(alCustomizationSettings.isStartNewFloatingButton() ? View.VISIBLE : View.GONE);

    swipeLayout = (SwipeRefreshLayout) list.findViewById(R.id.swipe_container);
    swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    recyclerView.setLongClickable(true);
    registerForContextMenu(recyclerView);
    ((CustomToolbarListener) getActivity()).setToolbarTitle(ApplozicService.getContext(getContext()).getString(R.string.conversation));

    return list;
}