How to disable the shadow around card view in android

后端 未结 12 1939
陌清茗
陌清茗 2021-02-01 11:34

Hello I am am working on demo application in which i am using the card view of support library. By default it is adding shadow around it. I want to remove this shadow & shou

12条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 12:26

    CardView sets its own elevation during initialization, which will override whatever you set from XML. You should file this as a bug at chek this

    @Override
    public void initialize(CardViewDelegate cardView, Context context, int backgroundColor,
            float radius) {
        cardView.setBackgroundDrawable(new RoundRectDrawable(backgroundColor, radius));
        View view = (View) cardView;
        view.setClipToOutline(true);
        view.setElevation(context.getResources().getDimension(R.dimen.cardview_elevation));
    }
    

提交回复
热议问题