Change expandable indicator in ExpandableListView

前端 未结 7 800
野趣味
野趣味 2020-11-29 18:51

Trying to create an ExpandableListView. The initial view with the groups shows up fine. However, when I click the list item, my arrow does not change. See the images below.<

7条回答
  •  心在旅途
    2020-11-29 19:44

    subject:

        int width = getResources().getDisplayMetrics().widthPixels;
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
            listView.setIndicatorBounds(width - getPixelValue(40), width - getPixelValue(10));
        } else {
            listView.setIndicatorBoundsRelative(width - getPixelValue(40), width - getPixelValue(10));
        }
    

    and helper method:

    public static int getPixelValue(int dp) {
    
        final float scale = getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }
    

提交回复
热议问题