car/src/main/java/androidx/car/widget/ListItemAdapter.java
private ViewGroup createListItemContainer() {
        ViewGroup container;
        if (mBackgroundStyle == BackgroundStyle.CARD) {
            CardView card = new CardView(mContext);
            RecyclerView.LayoutParams cardLayoutParams = new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            cardLayoutParams.bottomMargin = mContext.getResources().getDimensionPixelSize(
                    R.dimen.car_padding_1);
            card.setLayoutParams(cardLayoutParams);
            card.setRadius(mContext.getResources().getDimensionPixelSize(R.dimen.car_radius_1));
            card.setCardBackgroundColor(mListItemBackgroundColor);

            container = card;
        } else {
            FrameLayout frameLayout = new FrameLayout(mContext);
            frameLayout.setLayoutParams(new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            // Skip setting background color for NONE.
            if (mBackgroundStyle != BackgroundStyle.NONE) {
                frameLayout.setBackgroundColor(mListItemBackgroundColor);
            }

            container = frameLayout;
        }
        return container;
    }
/**
     * Creates a view with background set by {@link BackgroundStyle}.
     */
Creates a view with background set by  BackgroundStyle.
Creates a view with background set by BackgroundStyle .
private ViewGroup createListItemContainer() {
        ViewGroup container;
        if (mBackgroundStyle == BackgroundStyle.CARD) {
            CardView card = new CardView(mContext);
            RecyclerView.LayoutParams cardLayoutParams = new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            cardLayoutParams.bottomMargin = mContext.getResources().getDimensionPixelSize(
                    R.dimen.car_padding_1);
            card.setLayoutParams(cardLayoutParams);
            card.setRadius(mContext.getResources().getDimensionPixelSize(R.dimen.car_radius_1));
            card.setCardBackgroundColor(mListItemBackgroundColor);
            container = card;
        } else {
            FrameLayout frameLayout = new FrameLayout(mContext);
            frameLayout.setLayoutParams(new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            if (mBackgroundStyle != BackgroundStyle.NONE) {
                frameLayout.setBackgroundColor(mListItemBackgroundColor);
            }
            container = frameLayout;
        }
        return container;
    }
private ViewGroup createListItemContainer ( ) { ViewGroup container ; if ( mBackgroundStyle == BackgroundStyle . CARD ) { CardView card = new CardView ( mContext ) ; RecyclerView . LayoutParams cardLayoutParams = new RecyclerView . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ; cardLayoutParams . bottomMargin = mContext . getResources ( ) . getDimensionPixelSize ( R . dimen . car_padding_1 ) ; card . setLayoutParams ( cardLayoutParams ) ; card . setRadius ( mContext . getResources ( ) . getDimensionPixelSize ( R . dimen . car_radius_1 ) ) ; card . setCardBackgroundColor ( mListItemBackgroundColor ) ; container = card ; } else { FrameLayout frameLayout = new FrameLayout ( mContext ) ; frameLayout . setLayoutParams ( new RecyclerView . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ) ; if ( mBackgroundStyle != BackgroundStyle . NONE ) { frameLayout . setBackgroundColor ( mListItemBackgroundColor ) ; } container = frameLayout ; } return container ; }
Creates a view with background set by {@link BackgroundStyle}.
Creates a view with background set by { @link BackgroundStyle } .
// Skip setting background color for NONE.