SetAlpha to view background in lollipop not working

I am developing an android app that has background photos so I decided to make my listViewView or recyclerView transparent to show these backgrounds everything works well except for the lollipop version!

this is lollipop version looks likethis is kitkat version looks like

I want to make a lollipop version like all previous versions like kitkat here is the code snippet I use to set the transparency of each element

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder mHolder;
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.dairy_item, parent, false);
            CardView listItem = (CardView) convertView.findViewById(R.id.dairy_card);
            listItem.setCardElevation(5);
            listItem.setUseCompatPadding(true);
            // listItem.setPadding(0, 0, 5, 6);
            listItem.setPreventCornerOverlap(true);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                Drawable mBackground = listItem.getBackground();
                mBackground.setAlpha(127);
                listItem.setBackground(mBackground);
            } else {
                listItem.getBackground().setAlpha(127);
            }
            mHolder = new ViewHolder();
            mHolder.typeIcon = (ImageView) convertView.findViewById(R.id.reminder_icon);
            mHolder.title = (TextView) convertView.findViewById(R.id.reminder_identifier);
            mHolder.subtitle = (TextView) convertView.findViewById(R.id.reminder_status);
            mHolder.time = (TextView) convertView.findViewById(R.id.item_time);
            mHolder.order = (TextView) convertView.findViewById(R.id.item_order);
            convertView.setTag(mHolder);
        } else
            mHolder = (ViewHolder) convertView.getTag();

        mHolder.typeIcon.setImageResource(imgRec[position]);
        mHolder.title.setText(title[position]);
        mHolder.subtitle.setText(subtitle[position]);
        String orders = String.valueOf(position + 1);
        if (SettingsFragment.isArabic(mContext))
            orders = Referances.ArabtizeDigits(mContext, orders);
        mHolder.order.setText(orders);
        mHolder.time.setText(time[position]);

        return convertView;
    } 

      

from my own listView adapter. thanks in advance....

+3


source to share





All Articles