Expandable list view move group icon indicator to right in jellyBean 4.3 version?

笑着哭i 提交于 2019-12-17 23:13:44

问题


The below method is not working in android version jellybean 4.3.

historyExpaLV.setIndicatorBounds(historyExpaLV.getRight() - 60,
                    historyExpaLV.getWidth() - 8);    

Does anyone know the solution? Thanks in advance.


回答1:


How I fixed this:

Update SDK Manager to Android 4.3 and use it as build target. They introduced a new method in the API 18, called setIndicatorBoundsRelative(int, int), which works as the other (but correctly) in android 4.3.

Make a check for Android version and use the old method with older API:

if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
   mListView.setIndicatorBounds(myLeft, myRight);
} else {
   mListView.setIndicatorBoundsRelative(myLeft, myRight);
}



回答2:


i think it's bug

int right = (int) (getResources().getDisplayMetrics().widthPixels - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics()));
    expandableListView.setIndicatorBounds(right - getResources().getDrawable(R.drawable.group_indicator_padding).getIntrinsicWidth(), right);

this code works fine up to 4.2.2 and do nothing on 4.3



来源:https://stackoverflow.com/questions/17995491/expandable-list-view-move-group-icon-indicator-to-right-in-jellybean-4-3-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!