Expandable list view move group icon indicator to right

前端 未结 16 2458
栀梦
栀梦 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:44

    Try this... this code for adjusting the ExpandableList group indicator into right side of the view.

    private ExpandableListView expandableListView;
    DisplayMetrics metrics;
    int width;
    metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    width = metrics.widthPixels;
    expandableListView = (ExpandableListView) findViewById(R.id.expandableListView1);
    expandableListView.setIndicatorBounds(width - GetDipsFromPixel(50), width - GetDipsFromPixel(10));
    

    And call this method,

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

    The result is.. ExpandableList right side group indicator

提交回复
热议问题