How to change ExpandableListView group indicator position?

前端 未结 3 1797
执念已碎
执念已碎 2021-02-04 14:28

I want to change the ExpandableListView group indicator to right with padding.

I used custom adapter to load data to ExpandableListV

3条回答
  •  没有蜡笔的小新
    2021-02-04 14:39

    private void setGroupIndicatorToRight() {
        /* Get the screen width */
            DisplayMetrics dm = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(dm);
            int width = dm.widthPixels;
            expandableList.setIndicatorBounds(width - getDipsFromPixel(35), width - getDipsFromPixel(5));
        }
        // 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 + 250.5f);
        }
    

提交回复
热议问题