Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6535919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:25:48+00:00 2026-05-25T10:25:48+00:00

I have a ListView with rounded corners made using following shape as background: <?xml

  • 0

I have a ListView with rounded corners made using following shape as background:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:bottomRightRadius="13px" android:bottomLeftRadius="13px" android:topLeftRadius="13px" android:topRightRadius="13px"/>
</shape>

The problem lies in the selector. It’s rectangle shaped, so when selecting first or last item the corners aren’t rounded anymore. I’ve found a very nice solution in the last post at http://www.anddev.org/view-layout-resource-problems-f27/rounded-corners-on-listview-t8193-15.html. The problem is I can’t make another class to inherit from ListView. How can I apply this method when the only thing I have is the reference to existing ListView? The reason I have to do it this way is that the layout is inflated from xml.

I’m looking for something like:

ListView lv = (ListView)findViewById(...);
lv.onSizeChanged = protected void onSizeChanged(int w, int h, int oldw, int oldh){ ... }

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:25:48+00:00Added an answer on May 25, 2026 at 10:25 am

    Looks like there’s no other way than extending the ListView class and using it in XML. Here’s the sample code:

    public class WListView extends LinearLayout
    {
        // =================================================================
        // Variables
        // =================================================================
        private Path clipArea;
    
        // =================================================================
        // Public methods
        // =================================================================
    
        public WListView(Context context)
        {
            super(context);
        }
    
        public WListView(Context context, AttributeSet attr)
        {
            super(context, attr);
        }
    
        // =================================================================
        // Private methods
        // =================================================================
    
    
        @Override
        protected void onSizeChanged(int w, int h, int oldW, int oldH)
        {
            super.onSizeChanged(w, h, oldW, oldH);
            clipArea = new Path();
            RectF rect = new RectF(0, 0, w, h);
    
            int cornerRadius = 13; // we should convert px to dp here
            clipArea.addRoundRect(rect, cornerRadius, cornerRadius, Path.Direction.CW);
        }
    
        @Override
        protected void dispatchDraw(Canvas canvas)
        {
            canvas.save();
            canvas.clipPath(clipArea);
            super.dispatchDraw(canvas);
            canvas.restore();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom drawable rounded_corner.xml: <?xml version=1.0 encoding=UTF-8?> <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <gradient android:startColor=#FFFFFF
I have this Listview element: <ListView android:id=@+id/category_list android:layout_width=fill_parent android:layout_height=fill_parent android:layout_weight=1 android:background=@drawable/list_background android:layout_marginTop=10sp android:layout_marginLeft=10sp android:layout_marginRight=10sp
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a ListView control that is in FullRowSelect mode, MultiSelect off and using
We have ListView.Groups in .NET. Is there an equivalent in Qt (without using Windows
I have a listview that is binded to a ThreadSafeObservableCollection. The background of each
I have a ListView in a XML layout but I want to override one
I have a listview that loads dynamic controls from xml/xslt <asp:ListView ID=DynamicFields runat=server DataSourceID=CustomFields
I have a list view which items use a rounded-corner image for a background.
I have a ListView control, and I'm trying to figure out the easiest/best way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.