如何更改ExpandableListView组指示器位置?

我想用填充更改ExpandableListView 组指示器

我使用自定义适配器将数据加载到ExpandableListView

这是我的ExpandableListView xml。

   

这是GroupView xml

   

这是ChildView xml

    

这是输出图像,我想为此指标设置保证金。

在此处输入图像描述

setIndicatorBounds(int,int)对Android 4.3无效。 他们引入了一个新方法setIndicatorBoundsRelative(int,int) ,它适用于4.3。

 public int GetPixelFromDips(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); } @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) { explvList.setIndicatorBounds(width-GetPixelFromDips(35), width-GetPixelFromDips(5)); } else { explvList.setIndicatorBoundsRelative(width-GetPixelFromDips(35), width-GetPixelFromDips(5)); } } 
 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); }