0

Dose anyone know how to make the radius can always show on top when I scrolling the ListView?

enter image description here

enter image description here

enter image description here

I am using BaseAdapter to implement the first & last item background.

Here is the adapter code,

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if(this.dataset != null && !this.dataset.isEmpty() && this.dataset.size() > 0){
        if(convertView == null){
            convertView = inflater.inflate(R.layout.corner_list_item_layout, null);
        }

        ViewHolder holder = (ViewHolder) convertView.getTag();
        if(holder == null){
            holder = new ViewHolder();  
            holder.item = (RelativeLayout) convertView.findViewById(R.id.corner_list_item_relativelayout);
            holder.label = (TextView) convertView.findViewById(R.id.corner_list_item_label);
            convertView.setTag(holder);
        }           

        if (position == 0) {
            if (position == (this.getCount() - 1)) {
                holder.item.setBackgroundResource(R.drawable.app_list_corner_round_light);
            } else {
                holder.item.setBackgroundResource(R.drawable.app_list_corner_round_top_dark);
            }
        } else if (position == (this.getCount() - 1)) {
            if(position % 2 == 0){
                holder.item.setBackgroundResource(R.drawable.app_list_corner_round_bottom_dark);
            }else{
                holder.item.setBackgroundResource(R.drawable.app_list_corner_round_bottom_light);
            }

        } else {
            if(position % 2 == 0){
                holder.item.setBackgroundResource(R.drawable.app_list_corner_middle_dark);
            }else{
                holder.item.setBackgroundResource(R.drawable.app_list_corner_middle_light);
            }
        }

        String str = String.valueOf(this.dataset.get(position));        
        holder.label.setText(str);

    }
    return convertView;
}`
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
Rebecca
  • 85
  • 1
  • 8

1 Answers1

2
  1. Place the ListView inside any layout.
  2. Prepare a 9-patch border image and place this as a background to the Layout.

enter image description here

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295