Thursday, July 14, 2011

Expandable list view move group icon indicator to right

The setIndicatorBounds(int left, int right) is used to set the indicator bounds for the group view of an expandable list view.

explvList.setIndicatorBounds(width-GetDipsFromPixel(35), width-GetDipsFromPixel(5));

Here width means device width.


//Convert pixel to dip
public int GetDipsFromPixel(float pixels)
{
        // Get the screen's density scale
        final float scale = getResources().getDisplayMetrics().density;
        // Convert the dps to pixels, based on density scale
        return (int) (pixels * scale + 0.5f);

}

Note:

The imp point is indicator icon design.

The icon should be like this height of the icon is equal to parent view height with transparent background. In that we put our required image in the center.

The width is equal to width specified in the setBounds method. Here in my snippet it is 35.

Other wise the icon is disturbed.

Output :

No comments:

Post a Comment