Expandable list view move group icon indicator to right

前端 未结 16 2434
栀梦
栀梦 2020-12-04 08:56

As regards to expandable list view, the group icon indicator is positioned to the left side, can I move the indicator and positioned it to the right? Thanks.

16条回答
  •  不思量自难忘°
    2020-12-04 09:40

    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);
    } 
    

    FYI: The width is equal to width specified in the setBounds method. Here in my snippet it is 35.Other wise the icon is disturbed. For more details you may visit here:

    • https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBounds(int,%20int)

    • https://developer.android.com/reference/android/widget/ExpandableListView.html#setIndicatorBoundsRelative(int,%20int)

提交回复
热议问题